系统管理命令
. top
$man top 查看top的文档说明
DESCRIPTION
The top program provides a dynamic real-time view of a running system. It can dis-
play system summary information as well as a list of tasks currently being managed by
the Linux kernel. The types of system summary information shown and the types, order
and size of information displayed for tasks are all user configurable and that con-
figuration can be made persistent across restarts.
$top
显示的内容
top - 16:22:28 up 444 days, 22:20, 9 users, load average: 1.07, 1.16, 1.13
Tasks: 205 total, 2 running, 203 sleeping, 0 stopped, 0 zombie
Cpu(s): 79.1%us, 10.0%sy, 0.0%ni, 10.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.2%st
Mem: 8057792k total, 6794468k used, 1263324k free, 274912k buffers
Swap: 0k total, 0k used, 0k free, 3493820k cached
查看当前系统的资源和任务,3秒刷新一次
top当前时间,该主机运行多少天了,多少用户,负载情况
Task 多少任务在跑,一些任务情况
Cpu 一些指标
Mem内存的total ,used,free,buffers
Swap交换分区 ,类似windows中的虚拟内存概念
按q或者Ctrl+c退出浏览的状态
显示进程情况
PID USERID PR NI VIRT RES SHR S %CPU %MEM TIME+ COMAND
30441 ml 20 0 607m 129m 5900 R 99.3 1.6 10103:54 python
14067 root 20 0 302m 13m 3204 S 0.7 0.2 119:29.89 node_exporter
11060 zhangshk 20 0 15032 1312 936 R 0.3 0.0 0:01.01 top
11352 fosundb 20 0 4508m 488m 30m S 0.3 6.2 0:27.20 java
19175 root 20 0 2449m 75m 2884 S 0.3 1.0 1145:51 java
21140 root 20 0 1471m 61m 1968 S 0.3 0.8 332:04.32 python
22831 root 20 0 209m 10m 4544 S 0.3 0.1 185:20.36 AliYunDun
1 root 20 0 19344 860 556 S 0.0 0.0 0:19.82 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.23 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 9:16.87 migration/0
. free
DESCRIPTION
free displays the total amount of free and used physical and swap memory in the sys-
tem, as well as the buffers used by the kernel. The shared memory column represents
the ’Shmem’ value. The available memory column represents the ’MemAvailable’ value.
显示内存资源的使用情况
total used free shared buffers cached
Mem: 8057792 7200848 856944 25716 275228 3494716
-/+ buffers/cache: 3430904 4626888
Swap: 0 0 0
.netstat
DESCRIPTION
Netstat prints information about the Linux networking subsystem. The type of infor-
mation printed is controlled by the first argument, as follows:
下面是一些常用方式:
etstat[address_family_options] [–tcp|-t] [–udp|-u] [–raw|-w] [–listening|-l]
[–all|-a] [–numeric|-n] [–numeric-hosts][–numeric-ports][–numeric-ports] [–sym-
bolic|-N] [–extend|-e[–extend|-e]] [–timers|-o] [–program|-p] [–verbose|-v]
[–continuous|-c] [delay]netstat {–route|-r} [address_family_options] [–extend|-e[–extend|-e]] [–ver-
bose|-v] [–numeric|-n] [–numeric-hosts][–numeric-ports][–numeric-ports] [–con-
tinuous|-c] [delay]netstat {–interfaces|-I|-i} [iface] [–all|-a] [–extend|-e] [–verbose|-v] [–pro-
gram|-p] [–numeric|-n] [–numeric-hosts][–numeric-ports][–numeric-ports] [–con-
tinuous|-c] [delay]netstat {–groups|-g} [–numeric|-n] [–numeric-hosts][–numeric-ports][–numeric-
ports] [–continuous|-c] [delay]
netstat {–masquerade|-M} [–extend|-e] [–numeric|-n] [–numeric-hosts][–numeric-
ports][–numeric-ports] [–continuous|-c] [delay]netstat {–statistics|-s} [–tcp|-t] [–udp|-u] [–raw|-w] [delay]
- -t:表示TCP网络协议,三次握手,更安全
- -u:表示UDP网络协议,直接传输数据,传输快,不稳定
- -l:表示监听端口,listen
- -r:表示路由器,查看网关
- -n:表示IP地址和端口号
查看系统已经开启的监听端口
[kuerl@app02 ~]$ netstat -tlun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:12000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:38080 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:10050 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:41384 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:9000 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:39274 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:19001 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
udp 0 0 115.29.170.55:123 0.0.0.0:*
udp 0 0 10.161.170.72:123 0.0.0.0:*
udp 0 0 127.0.0.1:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
查看系统已经开启的监听端口以及正在连接的网络程序
[kuerl@app02 ~]$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:12000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:38080 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:10050 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:41384 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:9000 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:39274 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:19001 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 10.161.170.72:22 10.165.99.202:44874 ESTABLISHED
tcp 401 0 115.29.170.55:39734 106.11.68.13:80 CLOSE_WAIT
tcp 0 0 10.161.170.72:10050 10.160.13.40:59024 TIME_WAIT
tcp 0 0 10.161.170.72:59704 10.47.112.117:7182 ESTABLISHED
tcp 0 0 10.161.170.72:42544 172.17.18.30:22 ESTABLISHED
tcp 0 0 10.161.170.72:10050 10.160.13.40:59598 TIME_WAIT
tcp 0 0 10.161.170.72:10050 10.160.13.40:33816 TIME_WAIT
查看路由信息
[kuerl@app02 ~]$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
101.95.11.42 115.29.171.247 255.255.255.255 UGH 0 0 0 eth1
116.228.185.132 115.29.171.247 255.255.255.255 UGH 0 0 0 eth1
10.160.13.40 10.161.175.247 255.255.255.255 UGH 0 0 0 eth0
115.29.168.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1
10.161.160.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
172.16.0.0 10.161.175.247 255.240.0.0 UG 0 0 0 eth0
100.64.0.0 10.161.175.247 255.192.0.0 UG 0 0 0 eth0
10.0.0.0 10.161.175.247 255.0.0.0 UG 0 0 0 eth0
0.0.0.0 115.29.171.247 0.0.0.0 UG 0 0 0 eth1