1 , viewing the system load command
W command: Main view CPU Load
Load average: Load within five minutes of load for 15 minutes within one minute
The load is related to the number of CPU cores and the number of CPU cores viewed:
# Cat/proc/cpuinfo | grep ' Processor ' | Wc-l
Uptime can also display CPU load
2 , Vmstat command
# vmstat 1 5
1 represents once per second, 5 represents five times
R column: Represents a process that runs within one second
Column B: Blocked process
SWPD column: How much data is exchanged, in kilobytes
Free column: Remaining memory
Buff Column: Buffering
Cache columns: Caching
Si column: Swap in enter into memory data
So column: Swap out read out of memory
BI columns: Read disk, normal server hard disk continues to exceed 1000 note server pressure read frequently
Bo Column: Write disk
In column: Number of endpoints
CS Column: Context switch
US column: Percentage of CPU consumed by the user-state process
SY column: Kernel-state process consumes percent of CPU,
ID Column: Idle
WA column: Waiting
St Column: Stolen
3 , top command
PID: Under the/proc directory
User: The process to which users run
FR: Value range 0 to 39, process priority, lower value priority higher
NI: Value range 20 to 19, process priority
VIRT: Total amount of virtual memory used by the process =swap+res
RES: The physical memory that the process uses, not swapped out
SHR: Contributing Memory
S: Process state d= non-interruptible sleep state r= run s= sleep t= track/stop z= zombie Process
%CPU:CPU usage Rate
%MEM: Memory Utilization
Time+: Time to use CPU
COMMAND: Process Name
4 , SAR command (view network card traffic)
# sar-n DEV 1 10
Display once per second, display 10 times, network card traffic statistics
The history of the SA is recorded in the/var/log/sa directory
Use the # sar-n dev-f sa27 to view the history of number 27th
# sar-q View Load
# sar-b View Disk
5 , free command
# FREE-M displays memory usage by megabytes, which by default is K
Total: Amount of memory
Used: Memory usage
Free: Memory remaining condition
Buffers: Data that will be written to disk in memory
Cached: Putting data from a disk into memory
6 , PS command
# How to use PS Aux:bsd style
User: The process to which users start
PID: Process ID
%cpu:cpu percent usage
%MEM: Percent Memory usage
VSZ: Virtual Memory size
RSS: The size of real memory
TTY: Terminal
STAT: Process state S: Hibernate, S main process;< high priority, N priority low, + foreground running process; R running process; l locked process; l multi-threaded process; z zombie process; x dead process; t paused process
Start: Startup time
Time: CPU-intensive
COMMAND: The name of the process
7 , netstat command
# NETSTAT-LNP View servers listening to those ports
# Netstat-an | grep 92.168.83.50:3402 | Grep-ic Estab View the number of connections
8 , Tcpdump, and Tshark tools
# tcpdump-nn-i Eth0-c 5
Crawl five packets on the eth0 NIC
# tcpdump-nn TCP and Port 22-c 5
# TCPDUMP-NN-S0 TCP and Port 22-c 10-w Test.cap
Tshark tools need to install Wireshark binary packages
# tshark-n-T a-r http.request-t fields-e "Frame.time"-E "ip.src"-E "http.host"-E "Http.request.method"-E "http.re Quest.uri "
9 , SELinux
View selinux Status: # Getenforce
Temporary shutdown selinux:# Setenforce 0
Permanently closed: # sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config
If the Libselinux-utils package is not installed with the Getenforce and Setenforce commands
Ten , NetFilter ---iptables firewall
Table-->chain Chain
# iptables-t FILTER-NVL//View the rules of the filter table
# iptables-t NAT-NVL//view NAT table rules
# iptables-t MANGLE-NVL//view rules for mangle tables
# iptables-t filter-a input-p tcp--dport 80-s 192.168.1.135-j REJECT
-T: Specifies the name of the table to manipulate
-A: Append a rule
-I: inserting a rule
-D: Delete a rule
-P: Set default rules
-P: Specify protocol
--dport: Specify port number
-S: Specify Source IP
-J: Specify the processing mode; REJECT: Reject; drop: discard; Accept: Acceptance
# Iptables-f//Empty firewall rules
# service Iptables save//Keep a well-written firewall rule permanently
# iptables-save >/tmp/iptbales Backup firewall rules
# Iptables-restore < iptables//recover firewall rules
INPUT drop;192.168.1.1/24 Accept;all, all of the accept;
#/bin/bash
Iptables= "/sbin/iptables"
$iptables-F
$iptables-P INPUT DROP
$iptables-P OUTPUT ACCEPT
$iptables-P FORWARD ACCEPT
$iptables-A input-s 192.168.1.1/24-p TCP--dport 22-j ACCEPT
$iptables-A input-p TCP--dport 80-j ACCEPT
$iptables-A input-p TCP--dport 21-j ACCEPT
$iptables-A input-p TCP--dport 22-j drop the remaining network segments do not allow connection to port 22
One , cron Scheduled Tasks
# crontab-l
-L: View task Schedule
-E: Edit Task Schedule
-r: Delete Task schedule
First paragraph *: minutes
Second segment *: Hours
Third paragraph *: day
Fourth paragraph *: month
Fifth paragraph *: week
A , System Services
# NTSYSV command belongs to NTSYSV package, no command can be installed, control boot-up service by a similar graphical interface
# Chkconfig--list can also use this command to see which services are booting from
# chkconfig VSFTPD on/off allows some services to turn on or off at boot time
# chkconfig--level 23456 vsftpd on specifies the open or closed state of some services at startup level
# CHKCONIFG--add 123 adds 123 service to the boot entry, but 123 must be in the/ETC/INIT.D directory and is an executable file
- , Linux logs
The core system log is stored in the/var/log/directory
Log format and storage in/etc/logrotate.conf and/etc/logrotate.d/directories
View log of User login history/var/log/wtmp The log cannot be viewed directly and can be viewed with the last
Viewing the history of invalid logins/var/log/btmp The log cannot be viewed directly and can be viewed with LASTB
/var/log/maillog Mail-related logs
/var/log/secure authentication-related logs, such as the FTP logon situation
/VAR/LOG/DMESG some hardware-related logs during system startup
- , Xargs, and exec use
# Find. -name passwd-exec cp {} {}.bak \;
# Find. -name passwd | Xargs-i cp {} {}.bak
Two commands execute the same result
# ls *.bak | Xargs Rm-rf can also delete files like this oh, very cool ...
the , Screen command
Nohup Sleep & Drop in the background exit terminal is not interrupted and logs are logged
Screen Command Input screen package
How to use:
# screen
Input commands such as top
Then press Ctrl+a+d to exit.
# Screen-ls Viewing background programs
# screen-r ID View background program
Press CTRL+D or ESC to exit screen
16. Curl Command
# Curl Www.baidu.com View Baidu's text page
# curl-i www.baidu.com View status information of Baidu, etc.
# curl-x61.135.169.125:80-i www.baidu.com Specify proxy server
# curl-x61.135.169.125:80-iv www.baidu.com View Browse Baidu Yes visit process
# curl-u Fanjinbao:fanjinbao www.fanjinbao.com Access User name Password page
# Curl-o http://www.baidu.com/img/bdlogo.png Direct download of bdlogo.png pictures
# Curl-o fanjinbao.png http://www.baidu.com/img/bdlogo.png Download and rename to Fanjinbao.png
Linux daily operation and maintenance management