• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

ss Command Examples in Linux

by admin

The ss (socket state) command is an information gathering utility similar to netstat but provides simpler output and syntax. The ss tool can provide information about established TCP connections or which ports the system may be listening on for inbound connections. This can help you diagnose problems related to clients and servers being unable to communicate with one another over the desired protocol; a missing socket could mean that the service isn’t running, and a closed socket could mean that either the client or the server is prematurely terminating the connection. Another way to use ss is to gather information about a particular client that may be connected.

Common options for the ss command include the following.

  • -l: Show currently listening sockets.
  • dst {host}: Show whether the specified host is connected and what the connection statistics are.
  • -i: Show only what ports are being listened on.

Syntax

The syntax of the ss command is:

# ss [options]

ss Command Examples

1. Show all TCP/UDP/RAW/UNIX sockets:

# ss -a -t|-u|-w|-x

2. Filter TCP sockets by states, only/exclude:

# ss state/exclude bucket/big/connected/synchronized/...

3. Show all TCP sockets connected to the local HTTPS port (443):

# ss -t src :443

4. Show all TCP sockets listening on the local 8080 port:

# ss -lt src :8080

5. Show all TCP sockets along with processes connected to a remote ssh port:

# ss -pt dst :ssh

6. Show all UDP sockets connected on specific source and destination ports:

# ss -u 'sport == :source_port and dport == :destination_port'

7. Show all TCP IPv4 sockets locally connected on the subnet 192.168.0.0/16:

# ss -4t src 192.168/16

Conclusion

The ss command is another utility used to view socket statistics, similar to the netstat command. The advantage of using ss is that it can display more TCP and connection state information than other tools that exist by default.

Filed Under: Linux

Some more articles you might also be interested in …

  1. aptitude Command Examples in Linux
  2. rdesktop Command Examples in Linux
  3. How to uninstall certbot software package in Ubuntu
  4. How to connect to an Active Directory Domain using Realmd (Configure CentOS/RHEL 7 as active directory client)
  5. taskset: command not found
  6. udevadm Command Examples in Linux
  7. cockpit-ws Command Examples in Linux
  8. loadkeys: command not found
  9. SSH Authentication Files in Linux
  10. fisher: Fisher, a fish-shell plugin manager

You May Also Like

Primary Sidebar

Recent Posts

  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples
  • “glab mr” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright