Linux常用命令

根据端口获取相关信息

[root@iZ28t57xzbcZ ~]# lsof -i:80
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd      1112   root    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
AliYunDun  1135   root   23u  IPv4  14521      0t0  TCP iZ28t57xzbcZ:46292->140.205.140.205:http (ESTABLISHED)
httpd      6681 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      6682 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      6683 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      6684 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      6685 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      8061 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd      8062 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd     10230 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd     11275 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)
httpd     13635 apache    3u  IPv4  14258      0t0  TCP *:http (LISTEN)

[root@iZ28t57xzbcZ ~]# netstat -anp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN                                                                                              1112/httpd
tcp        0      0 121.42.151.190:80       218.4.117.14:48395      TIME_WAIT                                                                                           -
tcp        0      0 121.42.151.190:46292    140.205.140.205:80      ESTABLISHED                                                                                         1135/AliYunDun
unix  2      [ ]         DGRAM                    9804     345/systemd-udevd

[root@iZ28t57xzbcZ ~]# ps -ef|grep httpd
root      1112     1  0 Sep17 ?        00:00:24 /usr/sbin/httpd -DFOREGROUND
apache    6681  1112  0 Sep20 ?        00:00:33 /usr/sbin/httpd -DFOREGROUND
apache    6682  1112  0 Sep20 ?        00:00:19 /usr/sbin/httpd -DFOREGROUND
apache    6683  1112  0 Sep20 ?        00:00:38 /usr/sbin/httpd -DFOREGROUND
apache    6684  1112  0 Sep20 ?        00:00:22 /usr/sbin/httpd -DFOREGROUND
apache    6685  1112  0 Sep20 ?        00:00:39 /usr/sbin/httpd -DFOREGROUND
apache    8061  1112  0 Sep20 ?        00:00:23 /usr/sbin/httpd -DFOREGROUND
apache    8062  1112  0 Sep20 ?        00:00:21 /usr/sbin/httpd -DFOREGROUND
apache   10230  1112  0 Sep21 ?        00:00:12 /usr/sbin/httpd -DFOREGROUND
apache   11275  1112  0 Sep22 ?        00:00:09 /usr/sbin/httpd -DFOREGROUND
apache   13635  1112  0 Sep22 ?        00:00:03 /usr/sbin/httpd -DFOREGROUND
root     14738 14693  0 11:09 pts/0    00:00:00 grep --color=auto httpd