Collect and organize common linux shell commands 1. view database cache [plain] show status like 'qca % '; show status like 'com _ sel %' on www.2cto.com '; [plain] myisamchk-r mmc_user_info_20070120.MYI database process [plain] show processlist firewall view [plain] iptables-nL 60028 II. Server-related www.2cto.com server connections view [plain] netstat-an | grep-c ": 3360 "querying mysql database connections netstat-an | grep ". 80 "| wc-l: view the number of online users ps-ef | grep http | wc-l: view apache concurrency netstat-anp | grep 80 | wc netstat-anp | grep 80 | grep EST | wc-l netstat-an | awk '/: 80/{print $5} '| awk-F ": "'{print $1}' | sort | uniq-c | sort-n netstat-nap | grep mysql netstat-n | awk '/^ tcp/{++ S [$ NF]} END {for (a in S) print, S [a]} '[plain] // view server time uptime // set date-s 2012 | 1 | 2 // set date-s 18:30:50 // synchronization time/ usr/sbin/ntpdate stdtime.gov.hk view server information [plain] // view Linux version information uname-a cat/proc/version cat/etc/issue lsb_release-a // view CPU information more /proc/cpuinfo // view the CPU model and number of logical cores cat/proc/cpuinfo | grep name | cut-f2-d: | uniq-c // Number of CPU running bits getconf LONG_BIT // number of physical CPUs cat/proc/cpuinfo | grep physical | uniq-c // view memory information more/proce/meminfo/ /view the full hardware information dmidecode // view the server model dmidecode | grep "Product Name" // number of processes pstree // Add the priority level of process 180 to 1 renice + 1 180 // terminate a PID process kill-9 PID // specify to execute/bin/ls at 5 + 3 days/bin/ls scheduled task [plain] after three days minute hour day month week command or script 01 1-3/2 ***. sh // write the command directly to the cyclic task echo "40 7 *** 2/root/sh">/var/spool/cron/root www.2cto.com // view the crontab of the automatic periodic task- l // Delete the automatic cycle task crontab-r // whether A port netstat-anlp is enabled | common instance of grep port [plain] // allow access to the specified port iptables-a input from the IP address -s 192.168.62.1-p tcp -- dport 22-j ACCEPT // disable the use of A port iptables-a input-p tcp -- dport 22-j DROP iptables-a input-p tcp -- dport 31-j REJECT [plain] // disable the QQ port iptables-d forward-p udp -- dport 8000-j REJECT // disable the icmp port # Except 192.168.62.1, prohibit others from pinging my host iptables-a input-I eth0-s 192.168.62.1/32-p icmp-m icmp -- icmp-type 8-j ACCEPT iptables-a input-I eth0 -p icmp-m icmp -- icmp-type 8-j DROP Service Management [plain] # Start sendmail service/etc/init. d/sendmail start // view the startup status of all services chkconfig -- list // view the startup status of a service chkconfig -- list | grep httpd // start and shut down the service connection/etc /rc. d/rc3.d/S55sshd # S boot start K shutdown stop 55 level followed by service name ln-s-f/usr/local/httpd/bin/apachectl/etc/rc. d/rc3.d/S15httpd