How to see open ports on Linux
The ss command is a great utility on Linux to see socket statistics, including opened network ports. As the tool has many options, it may not be very obvious at first what options to use. In this article we look at showing all available TCP/UDP ports that are in a listening state (TCP) or are opened (UDP) for incoming connections.
Show TCP/UDP and related process
ss -plunt
So what does this command do?
Option | Action performed |
---|---|
-l | State should be ’listening’ (TCP) |
-n | Numeric display, do not map service names (e.g. show 22 instead of ssh) |
-p | Include the process that opened the port |
-t | Show TCP ports |
-u | Show UDP port |
Want to see a little bit more information, including established connections? Consider using the easy to remember -plants option. Besides the established connections, it will also display a small summary at the top about the used network protocols and their state.