The sys admin's daily grind: socket statistics

Short Cut

Article from Issue 192/2016
Author(s):

Most sys admins use netstat to find out about the status of network sockets, but Charly knows a good shortcut.

A bunch of parameters control the behavior of netstat. Administrators can also happily combine options so that some netstat calls look like an armadillo has rolled across the keyboard. With ss (like socket statistics), there is an even more specific tool for this purpose. It comes from the iproute2 package [1] – just like its siblings bridge, rtacct, rtmon, tc, ctstat, lnstat, nstat, routef, routel, rtstat, and ip.

Because a running Linux uses several hundred or more ports, ss comes with plenty of filters. I mostly need the -t and -u parameters, which restrict the results to TCP or UDP sockets. Other parameters limit the list to raw, Datagram Congestion Control Protocol (DCCP), package, and Unix domain sockets.

Caution: The tool only displays TCP sockets for existing connections by default (established or close_wait). If I also want to see sockets in the lists status – as I usually do – I have to type ss -ta. If I only want the tool to pay attention to listening TCP sockets and suppress all others, I use ss -lt. If I add -p here, I can also see which process opened the socket. I need to use root privileges for this; otherwise, -p has no effect.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Querying Sockets with ss

    The unassuming ss utility is easy to understand and easy to type, but it adds some powerful options to your admin toolkit.

  • Charly's Column: Fish

    Columnist Charly serves up Fish as the "shellfish" of the day. His conclusion: tasty, but not something you would want every day.

  • Charly's Column: SSLScan

    If, like our author Charly, you manage SSL-secured servers, read on to discover a tool that you will definitely appreciate. It checks whether the complete security setup is up to date.

  • Charly's Column

    Without Network Address Translation (NAT) on many LANs, the IPv4 Internet address space would have been exhausted years ago. Still, it’s probably a good idea to check what comes through your NAT connections.

  • Charly's Column: lsof

    The shorter a command, the longer the list of support parameters. This rule applies to lsof, one of Charly’s favorite commands.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News