zoukankan      html  css  js  c++  java
  • part4课堂笔记

    (1)vim,vi;sed
    vi,vim,<----->sed (文本编辑工具)
    sed (非交互式的流处理文本编辑工具)
    vi,vim(交互式的文本编辑工具)

    (2)为啥使用vi,vim
    linux文本处理工具很多(vim,vi,Emacs)
    a.类unix系统使用vi,vim
    b.程序调运
    [root@localhost ~]# visudo
    [root@localhost ~]# crontab -e
    c.具有程序编辑的能力,可以辨别颜色
    [root@localhost ~]# mv vimrc-anliu .vimrc
    d.程序简单,速度快

    (3)vim 三种模式 (命令模式,插入模式,末行)

    命名模式----i,o,O,A,a---->插入模式
    <--------ESC-----------

    命令模式------------:-------> 末行
    <-----------ESC-------------

    命令模式:
    翻页:pgup,pgdn,ctrl +F,B
    光标移动:
    上下左右键;h--->左;j--->下;k---->上;l----->右
    w:下一个词首
    e:
    b:

    行内:到行首 home,^ ,0
    到行尾 end,$

    行间:到首行 gg ,1G
    到行 ,nG
    到末行,G

    删除:删除单个字符 x,del
    删除光标所在行,dd
    删除多行,3dd

    复制,粘贴
    yy,3yy
    p(下),P(上)

    查找
    /word (从上往下)
    ?word(从下往上)
    n :从前往后查看查找出的内容
    N:从后往前查看查找出的内容


    插入模式
    i,I :i--->在光标前插入,I--->在光标所在行的行首
    a,A:a--->在光标后插入,A--->在光标所在行的行尾
    o,O:o--->在光标下一行插入,O--->光标上一行

    末行模式
    :15 跳到15行
    :w
    :q
    :wq
    :w!
    :q!
    :wq!
    :e ~/filename 打开filename编辑
    :r ~/filename 读入
    :w ~/filename 另存为
    替换
    :s/old/new 光标所在行的第一个匹配内容
    :s/old/new/g 光标所在行的所有匹配内容
    :2,5 s/old/new 2,5行的第一个匹配内容
    :2,5 s/old/new/g 2,5行的所有匹配内容
    :% s/old/new/g 所有匹配内容(全文)
    :s/old/new/c 交互

    (4)vim 命令打开文件

    vim +15 filename
    vim + filename
    vim +/error filename #匹配的是光标下的第一行

    (5)基本操作
    v:按字符选
    V:按行选取
    ctrl+v : 块

    .重复上一次操作

    u:撤销
    ctrl+r:撤销上一次撤销的内容

    (5)末行模式配置
    ~/.viminfo ---->vim的末行历史命令
    ~/.vimrc ----->vim配置文件


    压缩解压缩

    (1)zip,unzip
    zip filename.zip file
    zip -r filename.zip dir
    zip -m filename.zip file
    zip filename.zip dir -x file
    zip -d filename.zip file

    unzip filename.zip
    unzip fillename.zip /root/
    unzip -n filename.zip /root/
    unzip -o filename.zip /root/
    unzip -v filename.zip

    (2)gzip,gunzip
    gzip *
    gzip -r /test #该目录下的文件压缩
    gzip -d
    [root@server01 test]# gzip -l test2.gz
    [root@server01 test]# gzip -dv test2.gz

    (3)bzp2,bunzip2

    bzip2压缩文件,将删除源文件。
    压缩后的文件名为XXX.bz2存在,再次压缩时,不提示文件存在,没有压缩;要实现压缩,添加参数 -f强制压缩。
    压缩后的文件名不是.bz2结尾,再次压缩式,不输出内容,已经压缩。

    [root@server01 test]# bzip2 -d test3.bz2
    bzip2: Output file test3 already exists.
    [root@server01 test]# ls
    123.out 1.zip 456.out dir1 dir2.zip test1 test1.zip test1zip.zip test2 test2.zip test3 test3.bz2 test3.zip test4 test5
    [root@server01 test]# cat test3
    [root@server01 test]# bzip2 -df test3.bz2
    [root@server01 test]# cat test3
    this is a test of test3

    [root@server01 test]# bzip2 -dv test3.bz2
    test3.bz2: done
    [root@server01 test]# bzip2 -v test2
    test2: 0.448:1, 17.867 bits/byte, -123.33% saved, 30 in, 67 out.

    [root@server01 test]# bzip2 -t test2.bz2
    [root@server01 test]# bzip2 -tv test2.bz2
    test2.bz2: ok

    [root@server01 test]# bzip2 -k test3

    (4)xz,unxz


    归档(打包)

    (1)tar
    tar xf exam.tar ;rm -rf exam.tar #解压并删除源文件
    (2)cpio


    软件安装
    (1)rpm
    a.yum(一次性解除依赖关系)
    配置yum源
    配置网络源(基础):a.找网络镜像站地址(国内yum源: 网易163 yum源,安装方法查看:http://mirrors.163.com/.help/ (我推荐)
    中科大的 yum源,安装方法查看:https://lug.ustc.edu.cn/wiki/mirrors/help
    sohu的 yum源,安装方法查看: http://mirrors.sohu.com/help/

    阿里云的 yum源,安装方法查看: http://mirrors.aliyun.com/repo/ (推荐)
    清华大学的 yum源,安装方法查看: https://mirrors.tuna.tsinghua.edu.cn/
    浙江大学的 yum源,安装方法查看: http://mirrors.zju.edu.cn/
    中国科技大学yum源,安装方法查看: http://centos.ustc.edu.cn/)
    b.配置:把下载下来的.repo的文件放在/etc/yum.repo.d/
    c.清理并重新生成缓存 yum clean all ;yum makecache

    配置网络源(epel):EPEL的全称叫 Extra Packages for Enterprise Linux 。EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如
    CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源。
    方法一:从基础源里找epel-release。 yum list | grep epel-release
    安装epel-release包。 yum install -y epel-release
    安装完成之后,会在/etc/yum.repo.d/生成两个epel.repo;epel-testing.repo.
    清理并重新生成缓存 yum clean all ;yum makecache。

    方法二:从镜像站上获取:wget https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
    安装:yum install epel-release-latest-7.noarch.rpm
    安装完成之后,会在/etc/yum.repo.d/生成两个epel.repo;epel-testing.repo.
    清理并重新生成缓存 yum clean all ;yum makecache。

    配置本地源:方法一:挂载光驱
    首先要把镜像放挂载在光驱上
    把光驱设备挂载在/media ;mount /dev/sr0 /media
    在/etc/yum.repo.d/下写配置文件:
    [myrepo]
    name=""
    baseurl=file:///media
    gpgcheck=0
    enabled=1
    持久挂载:echo "mount /dev/sr0 /media" >> /etc/rc.local
    清理并重新生成缓存 yum clean all ;yum makecache。

    方法二:挂载镜像



    方法三:利用tfp或者http


    官方网站的源配置:
    nginx:http://nginx.org/en/linux_packages.html#RHEL-CentOS
    mysql:https://dev.mysql.com/downloads/file/?id=489467


    b.rpm安装(不能一次性解除一类)
    rpm -ivh zip 安装
    l,q,e,R,f,F,U

    (2)源码安装
    第一步:安装依赖,gcc,gcc-c++,make,gcc-g77
    [root@server02 yum.repos.d]# yum install gcc gcc-c++ gcc-g77 make
    第二步:环境分析,对系统调优
    (略)
    第三步:下载源码包
    http://nginx.org/download/

    第四步:安装
    三部曲:预编译------》编译-------》安装

    创建一个安装目录:
    mkdir -p /opt/data/nginx/
    创建一个运行软件的用户
    groupadd nginx
    useradd -g nginx nginx
    预编译
    ./configure --prefix=/opt/data/nginx/ --with-http_stub_status_module --with-http_ssl_module
    解除依赖
    yum install pcre
    yum install pcre-devel
    再次预编译
    ./configure --prefix=/opt/data/nginx/ --with-http_stub_status_module --with-http_ssl_module
    接触依赖
    yum install openssl
    再次预编译
    ./configure --prefix=/opt/data/nginx/ --with-http_stub_status_module --with-http_ssl_module
    接触依赖
    yum install openssl-devel
    再次预编译
    ./configure --prefix=/opt/data/nginx/ --with-http_stub_status_module --with-http_ssl_module

    检查预编译是否成功,0成功,非0失败
    echo $?

    编译
    make
    echo $?

    安装
    make install
    echo $?

    进入安装目录启动程序
    cd /opt/data/nginx/cd sbin
    ./nginx

    查看程序进程
    ps -ef |grep nginx

    修改静态页面
    cd html/
    vim index.html

    关闭防火墙
    systemctl stop firewalld
    setenforce 0

    访问页面:
    http://192.168.42.202/

  • 相关阅读:
    OLT配置学习
    notepad配合正则表达式处理文本
    利用expect和sshpass完美非交互性执行远端命令
    yum 数据库报错与重构
    杀死dialog
    OLT配置说明
    freeradius下发限速信息字段
    debug调试日志和数据查询
    通过windows的超级终端连接华为交换机
    强制清除交换机端口所有配置
  • 原文地址:https://www.cnblogs.com/anttech/p/11748482.html
Copyright © 2011-2022 走看看