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.

ss -plunt

So what does this command do?

OptionAction performed
-lState should be ’listening’ (TCP)
-nNumeric display, do not map service names (e.g. show 22 instead of ssh)
-pInclude the process that opened the port
-tShow TCP ports
-uShow 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.

Learn more about ss

This article uses the ss command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: ss

ss cheat sheet

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon