How to view the Linux port occupancy

linux view the port occupancy

How to view the Linux port

1, lsof -i: port number

To view a certain occupancy ports, such as viewing port 8000 usage, lsof -i: 8000

# lsof -i:8000
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
lwfs    22065 root    6u  IPv4 4395053      0t0  TCP *:irdmi (LISTEN)

You can see port 8000 has been forwarded service lwfs occupied lightweight file system

 

2, netstat -tunlp | grep port number,

      Process case for viewing port number specified, such as viewing port 8000 case, netstat -tunlp | grep 8000

# netstat -tunlp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      4814/rpcbind        
tcp        0      0 0.0.0.0:5908                0.0.0.0:*                   LISTEN      25492/qemu-kvm      
tcp        0      0 0.0.0.0:6996                0.0.0.0:*                   LISTEN      22065/lwfs          
tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      38296/dnsmasq       
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      5278/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      5013/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      5962/master         
tcp        0      0 0.0.0.0:8666                0.0.0.0:*                   LISTEN      44868/lwfs          
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      22065/lwfs        
# netstat -tunlp | grep 8000
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      22065/lwfs          

Explain the meaning of several parameters:

                                

 -t (tcp) 仅显示tcp相关选项
                                 -u (udp)仅显示udp相关选项
                                 -n 拒绝显示别名,能显示数字的全部转化为数字
                                 -l 仅列出在Listen(监听)的服务状态
                                 -p 显示建立相关链接的程序名
 


 3、ps 19836

     (Check the corresponding port 19836 PID process information) \


 4, cd / proc / process ID (pid open the file resides)   

       ll see the directories in the file

    ll / proc / process ID

  Check for the PID process command and directory information service run commands 46778 and so on.

 

Published 13 original articles · won praise 1 · views 7827

Guess you like

Origin blog.csdn.net/weixin_40482816/article/details/85232150