Linux Cloud Automation Fundamentals 4 (System architecture, vim, management input and output, regular expressions)

Source: Internet
Author: User

    1. Linux system Architecture
      Linux is an inverted tree structure
      Everything in Linux is a file.
      These files are at the top of the system directory "/"/is the root directory
      /directory Below is a level two directory these directories are automatically created when the system is installed
      650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9C/5F/wKiom1lvayuS9PhpAAFcI89mDag721.png "title=" Screenshot from 2017-07-19 22-21-52.png "alt=" Wkiom1lvayus9phpaafci89mdag721.png "/>



2. The role of level two directories
/bin # #二进制可执行文件也就是系统命令
/sbin # #系统管理命令存放位置
/Boot # #启动分区, responsible for system startup
/Dev # #设备管理文件
/etc # #大多数系统管理文件
/Home # #普通用户的家目录
/lib # #32位系统库文件存放位置
/LIB64 # #64位系统库文件存放位置
/media # #系统临时设备挂载点
/MNT # #系统临时设备挂载点
/run # #系统临时设备挂载点
/OPT # #第三方软件安装位置
/proc # #系统信息
/root # #超级用户家目录
/srv,/var # #系统数据
/sys # #系统管理, mostly about the kernel
/tmp # #系统临时文件存放位置
/usr # #系统用户相关信息数据及用户自定义软件存放位置
3. Addressing the file
(1) Absolute path
File in the real location of the system, the file name begins with "/"

(2) Relative path
The file is abbreviated to a name in the current location, and the name does not start with a/, and the name automatically adds the value displayed by the PWD.
4. Regular expressions
(1) wildcard characters
* # # #匹配0到任意字符
? # # #匹配单个字符
[[: Alpha:]] # # #匹配单个字母
[[: Lower:]] # # #匹配单个小写字母
[[: Upper:]] # # #匹配单个大写字母
[[:d Igit:] # # # #匹配单个数字
[[: Alnum:]] # # #匹配单个数字或字母
[[:p UNCT:] # # # #匹配单个符号
[[: Space:]] # # #匹配单个空格
(2) {} indicates a nonexistent or existing
{1..9} # # #1-9
{A.. F} # # #a-F
{1,3,5} # # #135
{a,c,e} # # #a c E
{1..3} {A.. C} # # #1a 2a 3a 2a 2b 2c 3a 3b 3c multiplication operation


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9C/60/wKioL1lvdhWgSz4tAACu04bXMn0854.png "style=" float : none; "title=" screenshot from 2017-07-19 22-53-36.png "alt=" Wkiol1lvdhwgsz4taacu04bxmn0854.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9C/60/wKiom1lvdhXB82-1AABtt5vPUNM644.png "style=" float : none; "title=" screenshot from 2017-07-19 23-03-25.png "alt=" Wkiom1lvdhxb82-1aabtt5vpunm644.png "/>



[] Indicates the existence of the
[A-c] # # #aA BB CC
[A-c] # # #aA或者bB或者c
[1-3] # # #1或者2或者3
[145] # # #1或者4或者5
[^abc]| [!ABC] # # #除了a并且除了b并且除了c

~ # # #当前用户家目录
~username # # #指定的用户家目录
~+ # # #当前目录
~-# # #当前目录之前所在目录

. # # #当前目录
.. # # #当前目录的上一级

  1. Managing input and output
    In a Linux system, the standard input is numbered 0, the correct output is numbered 1, and the error output number is 2

    Perform "student" with ordinary users in the system
    Find/etc-name passwd
    Because the student user rights issue will have the following output
    Find: '/etc/pki/ca/private ': Permission denied # #没有进入权力, error
    Find: '/etc/pki/rsyslog ': Permission denied
    Find: '/etc/audit ': Permission denied
    /ETC/PASSWD # #正确输出
    Find: '/ETC/POLKIT-1/RULES.D ': Permission denied
    Find: '/etc/polkit-1/localauthority ': Permission denied
    Find: '/etc/dhcp ': Permission denied
    Find: '/etc/selinux/targeted/modules/active ': Permission denied
    Find: '/etc/lvm/archive ': Permission denied
    Find: '/etc/lvm/backup ': Permission denied
    Find: '/etc/lvm/cache ': Permission denied
    Find: '/ETC/GRUB.D ': Permission denied
    /ETC/PAM.D/PASSWD # #正确输出
    Find: '/etc/audisp ': Permission denied
    Find: '/etc/firewalld ': Permission denied
    Find: '/etc/cups/ssl ': Permission denied
    Find: '/etc/ipsec.d ': Permission denied
    Find: '/etc/libvirt ': Permission denied
    Find: '/ETC/SUDOERS.D ': Permission denied
    Find: '/etc/named ': Permission denied

    2. (1) Output redirection
    Find/etc-name passwd > File # #重定向正确输出 >


    Find/etc-name passwd 2> fi

    Le # #重定向错误输出 2>
    Find/etc-name passwd &> File # #重定向所有输出 &>


  2. 650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9C/90/wKiom1lyDa6hXz0FAAAjrxvEMy8929.png "title=" Screenshot from 2017-07-21 21-47-49.png "alt=" Wkiom1lyda6hxz0faaajrxvemy8929.png "/>

    650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9C/90/wKiom1lyDfnDgCNBAADhro1hoQw527.png "title=" Screenshot from 2017-07-21 21-50-13.png "alt=" Wkiom1lydfndgcnbaadhro1hoqw527.png "/>


    Note: 2>,&> will overwrite the contents of the source file.
    >file # #清空file

    Find/etc-name passwd >> File # #追加正确输出 >>
    Find/etc-name passwd 2>> File # #追加错误输出 2>>
    Find/etc-name passwd &>> File # #追加所有输出 &>>
    Note:>> 2>> &>> does not overwrite the contents of the source file, it will put the corresponding output characters at the end of the file



    (2) Input redirection: format input to File
    Tr ' A-Z ' A-Z ' < Westos cat > Westos <<eof
    HELLO
    World
    Eof



    3. Pipe symbol: |
    Pipe, the correct output of the previous command as the standard input for the command following the pipe character

    Ls/bin | Wc-l # #统计ls

    /bin the number of rows output by the command

    The output of the error (STDERR) in the system is not available through the pipeline.
    Use 2>&1 to change the wrong output number from 2 to 1.

    Tee copy output to specified location
    Date |tee file |wc-l # # #tee命令复制date命令的输出到file中, and statistics output line

    650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9C/91/wKiom1lyFCPQH8XNAADcP9y_fos856.png "title=" Screenshot from 2017-07-21 22-47-18.png "alt=" Wkiom1lyfcpqh8xnaadcp9y_fos856.png "/>

    4.vim        Command Mode # # # #

    (1) in Vim's command mode you can configure how VIM works
    : Set nu            # #行号添加
    : Set nonu        # #取消行号
    : Set mouse=a         # #添加鼠标选择
    : Set cursorline        # #行线显示

    The above settings are temporary,
    Permanent settings
    vim/etc/vimrc        ## #此文件为vim的配置文件, at the end of this file add the above parameters, The number of digits added to the file is not required:



    (2). The key word search in vim command mode
    /keyword
    n down match
    N up match

    (3). The management of characters in vim command mode
        ( 1. Copying of characters
    yl        # #复制一个字母
    y3l        # #复制3个字母
    yw        # #复制一个单词
    y3w        # #复制3个单词
    yy         # #复制一行
    y3y        # #复制3行
    p        # #复制完成后按 "P" Paste

        (2. Deletion of characters
    dl        # #删除一个字母
    d3l        # #删除3个字母
    dw        ## Delete a word
    d3w        # #删除3个单词
    dd        # #删除一行
    d3d        # #删除3行


    (3. Cutting of characters
    CL # #剪切一个字母
    C3L # #剪切3个字母
    CW # #剪切一个单词
    C3W # #剪切3个单词
    CC # #剪切一行
    C3C # #剪切3行
    ESC---> P # #剪切过后会进入到插入模式, be sure to exit insert mode when performing a paste action

    (4). Vim's Visual Mode # # # # # #

    Press "CTRL + V" in command mode to enter the visual mode
    In visual mode, you can select characters in the area

    Bulk add characters in visual mode
    *>> Ctrl + V Select the column to which you want to add characters
    *>> Press "I" into insert mode, write the characters to be added
    *>> Press ESC

    (5). Batch modifier characters # # # #

    :%s/original character/replace character # #只替换每一行中出现的第一个原有字符
    :%s/original character/replace character/g # #替换所有
    :%s/^\ *//g # #把全文行首的空格去掉, "^\ *" indicates the space at the beginning of the line



    (6). Vim's split-screen function # # #
    Ctrl+w S # # #上下分屏
    Ctrl+w V # # #左右分屏
    Ctrl+w C # # #关闭光标所在屏幕
    Ctrl+w up or down # # #光标移动到指定屏幕
    : SP File2 # #同时编辑当前文件和file2
    (7). VIM Cursor Movement #####
    in command mode
    : Number # #移动到指定的行
    G # #文件最后一行
    GG # #文件第一行

    In insert mode
    I # #光标所在位置插入
    I # #光标所在行行首
    A # #光标所在字符的下一个位置
    A # #光标所在行行尾
    O # #光标所在行下一行
    O # #光标所在行上一行
    S # #删除光标所在字符插入
    S # #删除光标所在行插入

    (8). Vim's exit mode
    : Q # #当用vim打开文件但没有对字符作任何操作时可直接退出
    : q! # #当用vim打开文件并对字符作操作, quit all operations
    : Wq # #保存退出
    : wq! # #强行保存退出, effective for Superuser and file owner

    (9). Vim Handbook # # # #
    Vimtutor # #vim的手册
    : Q # #退出vimtutor

    5.gedit


    CTRL + N # #在gedit中打开一个新的tab
    Ctrl+s # #保存文件
    Ctrl+o # #打开文件
    Ctrl+x # #剪切字符
    Ctrl + V # #粘贴字符
    CTRL + C # #复制字符
    Yelp Help:gedit # #gedit的图形手册


This article is from the "13122425" blog, please be sure to keep this source http://13132425.blog.51cto.com/13122425/1950088

Linux Cloud Automation Fundamentals 4 (System architecture, vim, management input and output, regular expressions)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.