Linux Utility Commands Collation

Source: Internet
Author: User
Tags disk usage

0. Basic commands

Linux basic Commands Collation

1. Compression decompression

tar -zcvf A.tar.gz a   #把a压缩成a. tar.gztar - ZXVF A.tar.gz     #把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       #把word_1用word_2替换, g means replace all, n means only the number of statistics is not replaced :1, $s/word_1/& /gn       #搜索整个文档中word_1的个数, and the following equivalence :%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)find /usr  "*.png" -size +1m  WC - # Count the number of rows that match the criteria find /usr  "*.png" -size +1m   #删除符合条件的 

3.3 Find the name of all files with the string "Hello" under Directory dirs

Find . | Xargs grep " 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 . | Xargs grep " IBM " -l   #只打印出文件名

4. Sorting

Cat  Sort-k2-R            #按第二列 (starting with technology),-R represents reverse, from large to small output  catsort -k1-N            #按第一列排序,-n Sort by number, by string by default  Cat Sort WC -L   #统计满足条件的个数

5. System Overhead

5.1 df--disk usage

DF      #列出各文件系统的磁盘空间占用情况 (unused) Total five columns: Size used Avail use% mountedonDF -H  #以更易读的方式显示 (convert as appropriate by K\m\g)

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 (simplified the single saying is Process Queue the length of the last time 1min,5min,15min load metric)

W

6. The awk command

Catfile_name |awk '{print $}'#输出第一列 (the default is a space slice)Catfile_name |awk-F':'  '{print "\ t" $ $}'            #-f Specify the cut symbol, output the 3rd columnCatfile_name |awk-F':' 'BEGIN {print "Name,id"} {print $ "," $ $} END {print "end_name,end_id"}'#BEGIN指定开头输出, end indicates the ending outputCatfile_name |awk-F':' '/keyword/{print $ {}'# output column with keyword keyword in one rowCatfile_name |awk-F':' '{print "filename:" filename ", linenumber:" NR ", Columns:" NF}'#内置变量FILENAME文件名, nr read record number, NF column numberCatfile_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 omit 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   " ^-    | WC -L  #grep regular matches with '-', Wc-l: Count the total number of rows that meet the criteria  ls -L |   grep   " ^-    >file_name1  #把满足结果的定位到file_name1, note: Clear and then locate   ls -L |   grep   " ^-  " >>file_name2  #把满足结果的输出到file_name2的后面, Note: Do not empty, continue storing  
on the original basis

Linux Utility Commands Collation

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.