1. To view the Port Usage command: lsof-i
[Root@www ~]# Lsof-i
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Nginx 2333 root 6u IPv4 6242 TCP *:http (LISTEN)
Nginx 2334 www 6u IPv4 6242 TCP *:http (LISTEN)
sshd 2349 root 3u IPv6 6283 TCP *:ndmp (LISTEN)
sshd 2349 Root 4u IPv6 6286 TCP *:ssh (LISTEN)
This returns the current usage of all open ports on Linux.
The first paragraph is the process, and the last column is the protocol to listen on, the IP and port number to listen to, and the state.
If the port number is a known common service (such as 80, 21, and so on), the protocol name is displayed directly, such as HTTP, FTP, SSH, and so on.
2. View the occupancy of a port: Lsof-i: Port number
[Root@www ~]#lsof-i:21
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
PURE-FTPD 2651 Root 4u IPv4 7047 TCP *:ftp (LISTEN)
PURE-FTPD 2651 root 5u IPv6 7048 TCP *:ftp (LISTEN)
This shows that port 21st is being used by PURE-FTPD and the state is listen.
Lsof Port View