Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux ss command

Linux ss command

Linux Command Reference Linux Command Reference

ss is a Linux command for viewing socket statistics. It is similar to netstat but faster and provides more detailed information about network connection states.

ss stands for Socket Statistics and is used to display and analyze the system's network connection status.

ss can display detailed information about TCP, UDP, and UNIX sockets and supports rich filtering features for debugging networks, monitoring network connections, and more.

Syntax format



ss [options]

Description of the options parameter:

Common usage

1. View all socket connections



ss -a

Display detailed information about all sockets in the system, including listening and non-listening connections.

** 2. View TCP connections**



ss -t

Display only the TCP connections of the current system.

** 3. View UDP connections**



ss -u

Display only the UDP connections of the current system.

** 4. View listening sockets**



ss -l

Display only sockets that are listening, excluding established connections.

** 5. Display process information associated with sockets**



ss -p

Display all process information related to network connections.

** 6. Display a summary of network connections**



ss -s

Display a summary of network connections, including the total number of sockets, TCP/UDP connection counts, and more.

** 7. Display IPv4 sockets**



ss -4

Display only IPv4 sockets.

** 8. Display IPv6 sockets**



ss -6

Display only IPv6 sockets.

** 9. View detailed TCP socket states and timer information**



ss -o

Display TCP socket timer information, useful for analyzing issues such as connection timeouts and TCP retransmissions.

Example

1. View all TCP connections and show processes



ss -t -a -p

Display all TCP connections along with the associated process information.

** 2. View listening TCP ports**



ss -t -l

This command displays only ports listening under the TCP protocol, useful for troubleshooting server port listening issues.

** 3. View all UDP connections**



ss -u -a

Display all UDP connection information in the system.

** 4. View connections on a specified port**



ss -t '( dport = :80 or sport = :80 )'

This command displays TCP connections related to port 80, useful for checking the network connections of a web service.

** 5. View memory usage of each socket**



ss -m

Display the memory used by each network connection, suitable for analyzing the memory footprint of network connections.

** 6. View IPv6 network connections**



ss -6 -t -a

Display all IPv6 TCP network connections.

** 7. Simple socket statistics summary**



ss -s

This command displays an overview of the system's network connections, including the number of TCP and UDP sockets and their states.

Linux Command Reference Linux Command Reference