Linux Command Line: Find Open Ports & Applications

Here is a command that lists all open ports on your system, and lets you know which applications opened them

# List all open ports and the processes that opened them
lsof -i -P -n | grep LISTEN


The output typically looks like this

COMMAND PID USER File Descriptor # IP Type Device # File Offset Protocol IP:port (LISTEN)


Sometimes the “COMMAND” column is not enough for you to know which process is listening to a particular port. In this case, use the command below to get more details

# Example: find out more about the process with PID 26123
ps fax | grep 26123


More details about the lsof options

lsof lists all open files and the processes that opened them:

  • -i selects both IPV4 and IPV6 addresses
  • -P displays the port number instead of the name of the port
  • -n displays the actual IP address instead of the host name