Common Linux shell command combinations

Source: Internet
Author: User

Serial number Task Command combination
1 Delete a 0-byte file Find. -type f-size 0-exec rm-rf {} \;
Find. Type F-size 0-delete
2 View processes, sorted by memory from large to small PS-E-O "%c:%p:%z:%a" |sort-k5-nr
3 Rank from large to small by CPU utilization PS-E-O "%c:%p:%z:%a" |sort-nr
4 Print the URL in the cache Grep-r-a jpg/data/cache/* | Strings | grep "http:" | Awk-f ' http: ' {print ' http: ' $ ';} '
5 View the number of concurrent requests for HTTP and their TCP connection status Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
6 Sed the root line in this article, matching the root line, replacing no with yes. Sed-i '/root/s/no/yes/'/etc/ssh/sshd_config
7 How to kill the MySQL process PS aux |grep mysql |grep-v grep |awk ' {print $} ' |xargs kill-9
Killall-term mysqld
Kill-9 ' Cat/usr/local/apache2/logs/httpd.pid '
8 Show services running Level 3 (learn about the cut's purpose, intercept data) ls/etc/rc3.d/s* |cut-c 15-
9 How to display multiple messages in the writing shell, with EOF Cat << EOF
+ ———————————————————— –+
| = = = Welcome to tunoff services = = = |
+ ———————————————————— –+
Eof
10 for use (e.g. to build a soft link to MySQL) Cd/usr/local/mysql/bin
For i in *
Do ln/usr/local/mysql/bin/$i/usr/bin/$i
Done
11 Take IP Address Ifconfig eth0 |grep "inet addr:" |awk ' {print $} ' |cut-c 6-
Ifconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.1′|cut-d:-f2 | awk ' {print '} '
12 The size of the memory Free-m |grep "Mem" | awk ' {print $} '
13 View 80-port connections and sort netstat-an-t | grep ": 80″| grep established | awk ' {printf '%s%s\n ", $5,$6} ' | Sort
14 View the number of concurrent requests for Apache and its TCP connection status Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
15 Count the size of all JPG files under the server Find/-name *.jpg-exec wc-c {} \;|awk ' {print $} ' |awk ' {A+=$1}end{print A} '
16 Number of CPUs Cat/proc/cpuinfo |grep-c Processor
17 CPU Load Cat/proc/loadavg
18 CPU Load Mpstat 1 1
19 Memory space Free
20 Disk space Df-h
21st If a partition space is found to be nearly exhausted, you can go to the mount point of the partition and use the command to find the file or directory that occupies the most space. Du-cks * | Sort-rn | Head-n 10
22 Disk I/O load Iostat-x 1 2
23 Network Load Sar-n DEV
24 Network error Netstat-i
Cat/proc/net/dev
25 Number of network Connections Netstat-an | Grep-e "^ (TCP)" | Cut-c 68-| Sort | uniq-c | Sort-n
26 Total number of processes PS aux | Wc-l
27 View Process Tree PS AUFX
28 Number of processes that can run Vmwtat 1 5
29 Check if DNS server is working properly, take 61.139.2.69 as an example Dig www.baidu.com @61.139.2.69
30 Check the number of currently logged in users W.H.O. | Wc-l
31 Log view, search Cat/var/log/rflogview/*errors
Grep-i error/var/log/messages
Grep-i fail/var/log/messages
Tail-f-N 2000/var/log/messages
32 Kernel log Dmesg
33 Time Date
34 Number of handles already open lsof | Wc-l
35 Network capture packet, direct output summary information to the file. Tcpdump-c 10000-i eth0-n DST port >/root/pkts
36 Then check the number of repetitions of the IP and order from small to large note "-t\ +0″ the middle is two spaces, less command usage." Less Pkts | awk {' printf $3″\n '} | Cut-d.-F 1-4 | Sort | uniq-c | awk {' printf $1″ ' $2″\n "'} | Sort-n-t\ +0
kudzu View network card model kudzu–probe–class=network
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.