The ss (Socket Statistics) command is a powerful utility in Linux used to display detailed information about network connections. It is a faster and more feature-rich alternative to the older netstat command. This guide explores the usage of ss, its options, and practical examples for managing network connections effectively.
If you’re looking for a reliable and high-performance hosting solution, Ava Hosting offers Linux VPS hosting with optimized network connectivity, making it an excellent choice for developers and system administrators who need stable and fast remote access.
To display all active connections, simply run:
ss
This command shows a summary of all established connections, including their states and addresses.
To view listening ports, use:
ss -l
This helps in identifying which services are currently listening for incoming connections.
To filter only TCP connections, run:
ss -t
To view only listening TCP connections, use:
ss -lt
To display UDP connections:
ss -u
To filter only listening UDP connections:
ss -lu
To see which processes are associated with network connections, run:
ss -p
This is useful for troubleshooting applications using network resources.
To display only IPv4 connections:
ss -4
For IPv6 connections:
ss -6
For an in-depth view of all network sockets, use:
ss -s
This provides an overview of network socket statistics, including established, listening, and closed connections.
To check which connections are using a specific port, for example, port 80:
ss -at '( dport = :80 or sport = :80 )'
This is useful for monitoring web server traffic.
For a continuously updating view of network activity, combine watch with ss:
watch ss -tulnp
This command refreshes every two seconds, displaying active connections, listening ports, and related processes.
The ss command is an essential tool for network monitoring and troubleshooting in Linux. It provides a faster and more detailed alternative to netstat, helping users analyze active connections, listening ports, and associated processes. Mastering ss can significantly enhance your network administration skills.