1. lsof -i: port number
2. netstat -tunlp|grep port number
You can view which process the specified port is occupied by
method/step
-
[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
-
[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
-
[Step 3] netstat -tunlp
netstat -tunlp is used to display tcp, udp ports and processes, etc., as shown below
-
[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