1.netstat 命令可以帮助检查本机的网络状况
实战应用1:公司内部的一个老服务运行在192.168.1.1:50060上,服务将于一周之后停用,再在要查一下本机上有没有进行在调用该服务。
[root@zbxelk ~]# netstat -pt可以输出PID及程序名:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhostname:16061 192.168.1.1:50060       ESTABLISHED 22000/java

是本机的16061端口在调192.168.1.1:50060上的服务,且本机16061端口上跑的是一个java程序,进程ID是22000
[root@zbxelk ~]# netstat -ant
[root@test21 ~]# netstat -lntup


2.lsof可以查看系统打开的文件,这里的“文件”包括/proc文件、磁盘文件、网络IO等
[root@test21 ~]# lsof /etc/passwd    哪个进程在占用/etc/passwd
[root@test21 ~]# lsof  -u username   列出某个用户打开的文件
[root@test21 ~]# lsof -c mysql       列出某个程序打开的文件信息
[root@test21 ~]# lsof   -u ^root     列出除某个用户外的被打开的文件信息
[root@test21 ~]# lsof -p 1           列出某个进程号打开的文件
[root@test21 ~]# lsof -p ^1          列出除某个进程号外被打开的文件
[root@test21 ~]# lsof -i             列出所有的网络连接
[root@test21 ~]# lsof -i:3306       列出谁在使用某个端口


3.ps命令是Process Status的缩写。ps命令用来列出系统中当前运行的那些进程
ps命令列出的是当前那些进程的快照,如果想要动态的显示进程信息,就可以使用top命令
[root@test21 ~]#ps -A   显示所有进程信息
[root@test21 ~]#ps -u root  //显示root进程用户信息
[root@test21 ~]# ps -ef    显示所有命令,连带命令行
[root@test21 ~]# ps -aux   显示所有包含其他使用者的行程

相关文章:

  • 2021-12-21
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-06-14
  • 2022-12-23
  • 2021-07-04
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-11
相关资源
相似解决方案