0. Basic commands
Linux basic Commands Collation
1. Compression decompression
TAR-ZCVF A.tar.gz a #把a压缩成a. tar.gztar-zxvf A.t #把a. tar.gz extract into a
2. Vim Summary
2.1 Vim Replacement
#把word_1用word_2替换, g means replace all, c means to replace each one needs to be confirmed
2.2 VIM Statistics The number of a string
: m,ns/word_1/&/gn #统计从m行到n行之间word_1的个数, n means just count not replaced:1, $s/word_1/&/gn # Search the entire document for the number of word_1, and the following equivalent:%s/word_1/&/gn
Delete a string in 2.3 vim
: m,ng/word_1/d #从第m行到第n行删除所有的word_1
3. File Search
3.1 locate--Search by file name
locate/bin/zip
3.2 find--Search through the various properties of the file in a given directory
FIND/USR "*.png"-size +1m #查找的目录范围是/usr, with a name ending with. png, larger than 1M (+1m,1m,-1m)"*.png WC- #统计符合条件的行数"*.png #删除符合条件的
3.3 Find the name of all files with the string "Hello" under Directory dirs
Find. | "IBM" #xargs是一条Unix和类Unix操作系统的常用命令. It does this by converting the argument list to small pieces to pass to other commands to avoid the problem of too long a parameter list. Find. | "IBM#只打印出文件名
4. Sorting
SORT-K2-R #按第二列 (starting with technology),-R for reverse, from large to small output sort-k1-#按第一列排序,-n sorted by number, by string by default # Statistics satisfies the number of conditions
5. System Overhead
5.1 df--disk usage
DF #列出各文件系统的磁盘空间占用情况 (unused) Total five columns: Size used Avail use% mounted on Df-h #以更易读的方式显示 (press k\m\g for proper conversion)
5.2 du--File Size
DF #列出本目录下, the size of the directory (the default count unit is k)df-h file name #以更易读的方式显示所查文件的大小
5.3 W--cpu Load measurement (simple is said to be the length of the process queue , the last time 1min,5min,15min load measurement)
W
6. The awk command
Cat file_name |Awk‘{Print $}‘#输出第一列 (the default is a space slice)Cat file_name |Awk-f‘:‘‘{print "\ T" $ $}‘#-f specify the cut symbol, output the 3rd columnCat file_name |Awk-f‘:‘‘BEGIN {print "Name,id"} {print $ "," $ $} END {print "end_name,end_id"}‘#BEGIN指定开头输出, end indicates the ending outputCat file_name |Awk-f‘: ' /keyword/{print $ ' # output a row with a keyword keyword the development column awk-f : ' {print" filename: "filename", linenumber: "NR", Columns: "Nf} #内置变量FILENAME文件名, nr read record, NF number of columns cat file_name | awk {count++} END { Print "Count:" Count} " #编程, last output total rows
7. Encoding Conversion
Iconv-f gbk-t utf-8-c text.txt-o text.out #-f:from-t:to-c ignore invalid output from output-o output file name
8. File attributes
chmod Property file name #更改文件属性r: 1 w:2 x:4chown owner file name chgrp Group name file Name
9. Piping | REDIRECT >
LS- l | grep "^-" | #grep regular match begins with '-', wc-l: Counts the total number of rows that meet the criteria Ls-l | ^-">#把满足结果的定位到file_name1, Note: First clear and reposition ls-l |" ^-#把满足结果的输出到file_name2的后面, note: Do not empty, continue to store on the original basis
Linux Utility Commands Collation