
{{ $('Map tags to IDs').item.json.title }}
How to Check Open Ports with ss Command
The ss
command (socket statistics) is a powerful tool used to investigate sockets and connections on Linux systems. It is often favored over the older netstat
command due to its speed and efficiency. This tutorial will guide you through using the ss
command to check open ports and active connections.
1. Understanding the ss Command
The basic syntax of the ss
command is:
ss [options]
This command can show both TCP and UDP connections, listening ports, and much more.
2. Checking Listening Ports
To view all open listening ports on your system, use the following command:
ss -tuln
Here’s what the options mean:
- -t: Display TCP sockets.
- -u: Display UDP sockets.
- -l: Show only listening sockets.
- -n: Show numerical addresses instead of resolving hostnames.
This command outputs a list of listening ports along with the associated IP addresses.
3. Viewing Established Connections
If you want to see all established connections, modify the command slightly:
ss -tu
This will display all active TCP and UDP connections, showing their state.
4. Filtering Results by Protocol
You can filter results to show only TCP or UDP connections by using the appropriate option:
- For TCP:
ss -t
- For UDP:
ss -u
5. Displaying Process Information
To show which processes are using the network connections, use the -p
option:
ss -tulnp
This command will include the PID and process name associated with each connection, providing valuable information for troubleshooting.
6. Conclusion
By following this tutorial, you have learned how to use the ss
command to check open ports and manage socket connections in Linux. Understanding how to inspect network connections is crucial for effective system administration and network troubleshooting. Explore additional options and combinations of the ss
command to gain further insights into your system’s network activity!