ss: How to show listening ports

Updated . Posted . Visible to the public. Repeats.

Note

netstat has mostly been superseeded by its more modern rewrite ss which nowadays comes pre-installed rather than netstat.
The most common options (especially all that are mentioned in this card) work the same way as they did with netstat

Sometimes it's necessary for you to check which ports are in use on your local machine and which process is using it. To list this information you can use the following command (which is pretty easy to memorize for Germans 🌷):

sudo ss -tulpn
  • t: tcp
  • u: udp
  • l: listening ports
  • p: process
  • n: network

Use sudo to see the name of the process.

Finding open ports in the ss output

You should look for rows with State: LISTEN.

Rows for local address 127.0.0.1 or ::1 (IPv6) can only be reached from your own PC:

Netid    State     Recv-Q    Send-Q       Local Address:Port       Peer Address:Port   Process   
tcp      LISTEN    0         1024             127.0.0.1:3000            0.0.0.0:*      users:(("ruby",pid=33985,fd=18))

Rows for local address 0.0.0.0 can be reached from other PCs on your network:

Netid    State     Recv-Q    Send-Q       Local Address:Port       Peer Address:Port   Process   
tcp      LISTEN    0         1024               0.0.0.0:3000            0.0.0.0:*      users:(("ruby",pid=38327,fd=17))
Daniel Straßner
Last edit
Daniel Schulz
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2018-01-15 12:54)