Learning Linux

4262 ワード

基礎知識
  • Background Process

  • CTRL+Zプロセスを保留し、バックグラウンドに入れる
    jobsは現在一時停止しているプロセスbg%Nを表示し、N番目のタスクをバックグラウンドで実行(%前にスペースがある)fg%Nを表示し、N番目のタスクをフロントでデフォルトbgを実行させ、fgが%Nを持たない場合は最後のプロセスに対する操作を示す!
    kill%N:N番目のバックグラウンドプロセスを殺す
  • Command

  • bc - An arbitrary precision calculator language
    cat - concatenate and print files
    cmp - compare two files byte by byte
    cut - remove sections from each line of files
    #   PATH  3   5 , ':'  
    echo ${PATH} | cut -d ':' -f 3,5
    #   export  12        
    export | cut -c 12-
    #   export   12   20   
    export | cut -c 12-20

    df - report file system disk space usage
    diff - compare files line by line
    du - estimate file space usage
    env - run a program in a modified environment
    env     shell           (       export      )
    export              
    set         、     、shell      

    file - determine file type
    gawk - pattern scanning and processing language
    grep, egrep, fgrep - print lines matching a pattern
    head - output the first part of files
    iconv-指定されたファイルの符号化を変換します.繁体字を簡体字に変換する例:
    iconv -f utf8 -t big5 vi.utf8 | iconv -f big5 -t gb2312 | iconv -f gb2312 -t utf8 -o vi.gb.utf8

    id - return user identity
    info - read Info documents
    less - file reading
    locale - display locale settings
    locate - find files by name
    od - dump files in octal and other formats
    >  echo abcdefghiklmnopqrstuvwxyz | od -A d -w10 -t xCoCdCc
    0000000   61   62   63   64   65   66   67   68   69   6b
             141  142  143  144  145  146  147  150  151  153
              97   98   99  100  101  102  103  104  105  107
               a    b    c    d    e    f    g    h    i    k
    0000010   6c   6d   6e   6f   70   71   72   73   74   75
             154  155  156  157  160  161  162  163  164  165
             108  109  110  111  112  113  114  115  116  117
               l    m    n    o    p    q    r    s    t    u
    0000020   76   77   78   79   7a   0a
             166  167  170  171  172  012
             118  119  120  121  122   10
               v    w    x    y    z   
    0000026

    rsync - a fast, versatile, remote (and local) file-copying tool
    localhost > ls -lrt /tmp/test/
    -rw-r--r--  1 zyd  staff  11  4 22 16:15 1.txt
    
    192.168.17.53 > ls -lrt /tmp/test/
    -rw-r--r--. 1 root root  2 4   15 13:09 1.txt
    -rw-r--r--. 1 root root 10 4   22 16:42 2.txt
    
    #       ,  :   ,    ;
    rsync -v -r --ignore-existing --delete /tmp/test 192.168.17.53:/tmp
    
    192.168.17.53 > ls -lrt /tmp/test/
    -rw-r--r--. 1 root root  2 4   15 13:09 1.txt
    
    #     :1.txt     ;2.txt   ;
    
    
    

    sed - stream editor for filtering and transforming text
    sort - sort lines of text files
    split - split a file into pieces
    stty - set the options for a terminal device interface
    tac - concatenate and print files in reverse
    tail - output the last part of files
    tee - read from standard input and write to standard output and files
    test - check file types and compare values
    time - calculate execute time
    >  time ls
    bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
    
    real	0m0.003s
    user	0m0.001s
    sys	0m0.002s

    tr - translate or delete characters
    type - query command type
    >  type -a ls
    ls   `ls --color=auto'    
    ls   /usr/bin/ls

    uname - print system information
    uniq - report or omit repeated lines
    wc - print newline, word, and byte counts for each file
    xargs - build and execute command lines from standard input
  • ショートカット
  • Ctrl+Dキーボード入力完了(End of file,EOF,End of input)
    Ctrl+Z:タスクを中断しますが、このタスクは終了しません.彼はまだプロセス中に保留中の状態を維持しているだけで、fg/bg操作を使用してフロントまたはバックグラウンドのタスクを継続することができます.
  • Help

  • man
    info
  • 注意すべき点
  • 二重引用符と単一引用符の違い:
  • >  name=zyd
    >  myname='my name is ${name}'
    >  echo ${myname}
    my name is ${name}
    >  myname="my name is ${name}"
    >  echo ${myname}
    my name is zyd

    ネットワーク
  • ncを用いて2台の機udp連通性
  • を測定する.
    A:nc -vul 12121
    B:nc-vu A 12121現在AとBは互いに通信可能