Skip to content

Instantly share code, notes, and snippets.

@dhoeric
Last active April 23, 2018 02:51
Show Gist options
  • Save dhoeric/61a8591eca10f7d7b4091734ec665a4e to your computer and use it in GitHub Desktop.
Save dhoeric/61a8591eca10f7d7b4091734ec665a4e to your computer and use it in GitHub Desktop.
[Check listening port] #troubleshoot #linux

Check all listening ports in server

$ sudo netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::25                   :::*                    LISTEN

Find PID on using specific port

$ sudo lsof -i :22
COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
sshd      923   root    3u  IPv4    8564      0t0  TCP *:ssh (LISTEN)
sshd      923   root    4u  IPv6    8566      0t0  TCP *:ssh (LISTEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment