回到顶部

阅读目录

centos 查看端口是否被使用(netstat 和 lsof)

[root@VM_2_29_centos ~]# netstat -anp | grep 9090
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      751/uwsgi           
tcp        0      0 127.0.0.1:9090          127.0.0.1:59336         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59376         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59346         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59344         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59372         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59398         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59340         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:9090          127.0.0.1:59348         TIME_WAIT   -                   
[root@VM_2_29_centos ~]# netstat -tunplp | grep 9090
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      751/uwsgi           
[root@VM_2_29_centos ~]# lsof -i:9090
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
uwsgi     751 root    3u  IPv4 20316315      0t0  TCP localhost:websm (LISTEN)
uwsgi   14997 root    3u  IPv4 20316315      0t0  TCP localhost:websm (LISTEN)
uwsgi   14998 root    3u  IPv4 20316315      0t0  TCP localhost:websm (LISTEN)

9090 是被查询的端口。

lsof ( list open files ):

是一个列出当前系统打开文件的工具。

netstat 选项:

-a或--all:显示所有连线中的Socket;
-n或--numeric:直接使用ip地址,而不通过域名服务器;
-p或--programs:显示正在使用Socket的程序识别码和程序名称;

-t或--tcp:显示TCP传输协议的连线状况;
-u或--udp:显示UDP传输协议的连线状况;
-p或--programs:显示正在使用Socket的程序识别码和程序名称;
-l或--listening:显示监控中的服务器的Socket;

 


^_^
请喝咖啡 ×

文章部分资料可能来源于网络,如有侵权请告知删除。谢谢!

前一篇: Error fetching command 'build_solr_schema': The 'solr' backend requires the installation of 'pysolr'. Please refer to the documentation. Command 'build_solr_schema' skipped
下一篇: django.db.utils.IntegrityError: UNIQUE constraint failed: blog_articlelike.article_id, blog_articlelike.ip
captcha