37 common Linux Shell Command combinations

Source: Internet
Author: User

Serial number Task Command combination
1 Delete 0-byte files Find.-type f-size 0-exec rm-rf {}\;
Find. type f-size 0-delete
2 View processes in a descending order of memory Ps-e-o "% C: % p: % z: % a" | sort-k5-nr
3 Sort by cpu utilization from large to small 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: "$2 ;}'
5 View the number of concurrent http requests and their TCP connection status Netstat-n | awk '/^ tcp/{++ S [$ NF]} END {for (a in S) print a, S [a]}'
6 Sed matches the Root line in this text and replaces 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 $2}' | xargs kill-9
Killall-TERM mysqld
Kill-9 'cat/usr/local/apache2/logs/httpd. pid'
8 Display the services enabled at level 3 (learn the purpose of cut and intercept data) Ls/etc/rc3.d/S * | cut-c 15-
9 How to display multiple information in a SHELL Cat <EOF
+ --------------------- +
| === Welcome to Tunoff services ===|
+ --------------------- +
EOF
10 For usage (for example, creating 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 IP address Retrieval Ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut-c 6-
Ifconfig | grep 'inet addr: '| grep-v '2017. 0.0.1' | cut-d:-f2 | awk '{print $1 }'
12 Memory size Free-m | grep "Mem" | awk '{print $2 }'
13 View and sort the connections on port 80 Netstat-an-t | grep ": 80" | grep ESTABLISHED | awk '{printf "% s \ n", $5, $6}' | sort
14 View the number of concurrent Apache requests and their 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 $1}' | awk '{a + = $1} END {print }'
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
21 If a partition is found to be nearly exhausted, you can enter the mount point of the partition and use the following command to find the most occupied files or directories. 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 Process count Ps aux | wc-l
27 View process tree Ps aufx
28 Number of processes that can be run Vmwtat 1 5
29 Check whether the DNS Server works normally. Here we use 61.139.2.69 as an example. Dig www.baidu.com @ 61.139.2.69
30 Check the number of users currently logged on Who | wc-l
31 View and search logs 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 opened handles Lsof | wc-l
35 Capture packets on the network and directly output the summary information to the file. Tcpdump-c 10000-I eth0-n dst port 80>/root/pkts
36 Check the number of IP duplicates and sort them in ascending order. Note that there are two spaces in the middle of "-t \ + 0". usage of the less command. Less pkts | awk {'printf $3 "\ n" '} | cut-d. -f 1-4 | sort | uniq-c | awk {'printf $1 "$2" \ n "'} | sort-n-t \ + 0
37 Kudzu view Nic 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.