1, lsof -i: port number
To view a certain occupancy ports, such as viewing port 8000 usage, lsof -i: 8000
lsof - i : 8080 : View 8080 port occupied lsof abc . TXT : displays to open the file abc . TXT process lsof - c abc : display abc process is now open files lsof - c - the p- 1234 : List processes No. 1234 process file opened the lsof - G gid : displaying a home gid of the process where the lsof + D / usr / local /: display file directory is turned process the lsof + D / usr /local /: as above, but will search the directory of time longer lsof - d 4 : Use display fd as 4 process lsof - i - U : show all open ports and UNIX domain files
2, netstat -tunlp | grep port number
Process case for viewing port number specified, such as viewing port 8000 case, netstat -tunlp | grep 8000
See all ports occupancy:
Check the specified port occupied: 8090 port
Commonly used commands:
netstat - ntlp // View all current tcp port netstat - ntulp | grep 80 // View all 80 ports use netstat - ntulp | grep 3306 // View all 3306 port usage
Parameter Description:
-t (tcp) display only tcp related options
-u (udp) udp display only the relevant option
-n refused to display an alias, to show all the converted digital to digital
-l lists only the Listen (listen) service state
-p display Links established program name
Reference URL: https: //www.runoob.com/w3cnote/linux-check-port-usage.html