What is the purpose of “lsof -i” in Linux?
The lsof -i command in Linux is used to display all open network sockets and the processes associated with them. It can show information on all open network connections in currently running processes, including TCP and UDP connections.
Specifically, the lsof -i command can display the following information:
- The IP address and port number of this machine
- the IP address and port number of the remote host
- The status of the connection (such as ESTABLISHED, LISTENING, etc.)
- The PID and name of the process belongs to
By using the lsof -i command, you can quickly check which processes are currently using network connections in the system, along with detailed information about the connections. This is very useful for system administrators, as it can help them detect network connection issues and identify processes occupying ports.