How to see open ports on Linux
How to show open network ports such as TCP and UDP?
Run the ss command and define TCP and UDP connections with at least -t and -u. Use supporting options to tune the provided information, such as using numeric values.
ss -pluntThe 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.