How to check which process the port is occupied by linux

1. lsof -i: port number

2. netstat -tunlp|grep port number

You can view which process the specified port is occupied by

Tools/Materials

 
  • linux, windows
  • xshell

method/step

 
  1.  

    [Step 1] lsof -i

    lsof -i is used to display eligible processes, lsof (list open files) is a tool that lists the current system open files. Execute the lsof -i command as the root user , as shown below

    How to check which process the port is occupied by linux?
  2.  

    [Step 2] lsof -i: port number

    lsof -i: port number, used to check the occupancy of a port, such as checking the usage of port 22, lsof -i: 22, as shown below

    How to check which process the port is occupied by linux?
  3. 3

    [Step 3] netstat -tunlp

    netstat -tunlp is used to display tcp, udp ports and processes, etc., as shown below

    How to check which process the port is occupied by linux?
  4. 4

    [Step 4] netstat -tunlp|grep port number

    netstat -tunlp|grep port number, used to view the process status of the specified port number, such as viewing the situation of port 22, netstat -tunlp|grep 22, as shown below

    How to check which process the port is occupied by linux?
     
     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325083884&siteId=291194637