How to use ss Command (Monitor Network Connections)

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

The ss command is a tool used to dump socket statistics and displays information in similar fashion (although simpler and faster) to netstat. The ss command can also display even more TCP and state information than most other tools. Because ss is the new netstat, we’re going to take a look at how to make use of this tool so that you can more easily gain information about your Linux machine and what’s going on with network connections.

The ss command-line utility can display stats for the likes of PACKET, TCP, UDP, DCCP, RAW, and Unix domain sockets. The replacement for netstat is easier to use (compare the man pages to get an immediate idea of how much easier ss is).

In this tutorial, we will illustrate How to use ss Command in Linux.

  • ss command without any options simply lists all the connections
ss
  •  List of both listening and non-listening ports using the -a option
ss -a
  •  Display listening sockets using the -l option 
ss -l
  • Usel -t option to list all TCP connection
ss -t
  • List all Listening TCP Connections
ss -lt
  • Also you can List all UDP Connections
ss -ua
  •  List all Listening UDP Connections
ss -lu
  • Also list Summary Statistics using -s flag
ss -s
  •  Display Process IDs of Sockets using -p flag
ss -p
  • Also Display IPv4 and Socket Connections
ss -4
  • Display IPv6 Socket Connections
ss -6
  • Filter Connections by Port Number to display all socket connections with a destination or source port of http
ss -at '( dport = :80 or sport = :80 )'
  • Also, you can do the previous steps with its name (http) as follows
ss -at '( dport = :http or sport = :http )'
  • You can use more one flag to filtering your output according to your needs
ss -ntlpua
  • Also you can make deep filtering as the same as the previous steps with grep command to get the specific value you searched on as shown below
ss -ntlpua | grep 80

Conclusion

That’s all

We showed you how to use ss command, with ss, you can get very detailed information about how your Linux machine is communicating with other machines, networks, and services; details about network connections, networking protocol statistics, and Linux socket connections.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook