ss Command: Tutorial & Examples
Show information about network connections
ss command is a utility in Linux that allows you to display information about network connections, routing tables, and a variety of other network-related information. It is
similar to the
netstat command, but it provides more information and is more efficient.
To use the ss command, you can simply type
ss followed by any number of options and arguments. Here are some examples of common options you can use with the ss command:
-t: Show only TCP sockets
-u: Show only UDP sockets
-l: Show only listening sockets
-a: Show both listening and non-listening sockets
-n: Show addresses and port numbers in numeric form
-p: Show the process ID and name of the program that owns each socket
For example, to display a list of all established TCP connections on your system, you could use the following command:
The output of the
ss command will show you a list of sockets, along with information such as the local and remote address and port, the state of the connection, and the process
ID and name of the program that owns the socket.
Here is an example of the output you might see:
State Recv-Q Send-Q Local Address:Port Peer Address:Port ESTAB 0 0 192.168.1.100:22 192.168.1.200:50847 ESTAB 0 0 192.168.1.100:80 192.168.1.150:58362 ESTAB 0 0 192.168.1.100:443 192.168.1.250:34782
In this example, you can see that there are three established TCP connections: one on port 22 (SSH), one on port 80 (HTTP), and one on port 443 (HTTPS). The local address and port are the address and port of the machine you are running the ss command on, and the peer address and port are the address and port of the remote machine the connection is established with.
CleverUptime uses the
ss command to detect open ports on a system and to configure the monitors accordingly to scan those ports from the internet.