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

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

ss command : alternate of netstat

September 27, 2014 by Sharad Chhetri

In case you are looking for alternate of netstat command, here is called ss command.
By default ss command is shipped with package called iproute (Advanced IP routing and network device configuration tools)

Introduction of ss

ss command is another utility to investigate sockets. It is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state informations than other tools. It is considered as alternate of netstat command also.

Check ss version

Use the -V argument with ss command. It will show the version information
# ss -V
ss utility, iproute2-ss130716

Examples with ss command utility

Example 1. Display only listening sockets . Use argument -l

# ss -l

Example 2. Display all listening and non listening sockets . Use argument -a

# ss -a

Example 3. Display TCP sockets. Use argument -t or –tcp. Try with -l argument, it will print all listening TCP sockets.

ss -t

Sample:

[root@nix ~]# ss -t
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
ESTAB       0      0                                          192.168.56.101:ssh                                           192.168.56.1:38153   
[root@nix ~]# 
[root@nix ~]# ss -tl
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
LISTEN      0      100                                             127.0.0.1:smtp                                                     *:*       
LISTEN      0      128                                                     *:ssh                                                      *:*       
LISTEN      0      100                                                   ::1:smtp                                                    :::*       
LISTEN      0      128                                                    :::ssh                                                     :::*       
[root@nix ~]#

Example 4. Display UDP sockets. Use the argument -u or –udp . Try with -l argument

ss -u

Sample:

[root@nix ~]# ss -u
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
[root@nix ~]# 
[root@nix ~]# ss -ul
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
UNCONN      0      0                                                       *:43923                                                    *:*       
UNCONN      0      0                                                       *:39372                                                    *:*       
UNCONN      0      0                                                       *:bootpc                                                   *:*       
UNCONN      0      0                                                       *:bootpc                                                   *:*       
UNCONN      0      0                                                       *:mdns                                                     *:*       
UNCONN      0      0                                                       *:28977                                                    *:*       
UNCONN      0      0                                                      :::39372                                                   :::*       
UNCONN      0      0                                                      :::53064                                                   :::*       
[root@nix ~]#

Example 5. Show process using socket.Use argument -p or –processes. Try with other arguments

ss -p

Sample:

[root@nix ~]# ss -ltp
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
LISTEN      0      100                                             127.0.0.1:smtp                                                     *:*        users:(("master",1785,13))
LISTEN      0      128                                                     *:ssh                                                      *:*        users:(("sshd",1036,3))
LISTEN      0      100                                                   ::1:smtp                                                    :::*        users:(("master",1785,14))
LISTEN      0      128                                                    :::ssh                                                     :::*        users:(("sshd",1036,4))
[root@nix ~]# 

Example 6. Show socket memory usage. Use argument -m or –memory

ss -m

Sample:

[root@nix ~]# ss -mta
State       Recv-Q Send-Q                                      Local Address:Port                                          Peer Address:Port   
LISTEN      0      100                                             127.0.0.1:smtp                                                     *:*       
	 skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
LISTEN      0      128                                                     *:ssh                                                      *:*       
	 skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
ESTAB       0      0                                          192.168.56.101:ssh                                           192.168.56.1:38153   
	 skmem:(r0,rb87380,t0,tb23080,f4096,w0,o0,bl0)
LISTEN      0      100                                                   ::1:smtp                                                    :::*       
	 skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
LISTEN      0      128                                                    :::ssh                                                     :::*       
	 skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
[root@nix ~]#

The manual of ss utility is very helpful. To explore, use the command man ss for man pages. Or you use the command ss --help for getting help.

Reference of ss -help command

[root@nix ~]# ss -help
Usage: ss [ OPTIONS ]
       ss [ OPTIONS ] [ FILTER ]
   -h, --help		this message
   -V, --version	output version information
   -n, --numeric	don't resolve service names
   -r, --resolve       resolve host names
   -a, --all		display all sockets
   -l, --listening	display listening sockets
   -o, --options       show timer information
   -e, --extended      show detailed socket information
   -m, --memory        show socket memory usage
   -p, --processes	show process using socket
   -i, --info		show internal TCP information
   -s, --summary	show socket usage summary
   -b, --bpf           show bpf filter socket information

   -4, --ipv4          display only IP version 4 sockets
   -6, --ipv6          display only IP version 6 sockets
   -0, --packet	display PACKET sockets
   -t, --tcp		display only TCP sockets
   -u, --udp		display only UDP sockets
   -d, --dccp		display only DCCP sockets
   -w, --raw		display only RAW sockets
   -x, --unix		display only Unix domain sockets
   -f, --family=FAMILY display sockets of type FAMILY

   -A, --query=QUERY, --socket=QUERY
       QUERY := {all|inet|tcp|udp|raw|unix|packet|netlink}[,QUERY]

   -D, --diag=FILE     Dump raw information about TCP sockets to FILE
   -F, --filter=FILE   read filter information from FILE
       FILTER := [ state TCP-STATE ] [ EXPRESSION ]
[root@nix ~]# 

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. netstat command not found on CentOS 7 and RHEL 7 (Red Hat Enterprise Linux 7)
  2. FAQ on CentOS 7 / RHEL 7 : Alternate of ifconfig command
  3. Run cron job alternate week day
  4. Linux Tac Command : Reverse Of cat Command Output
  5. How To Find Absolute Full Path Of Command On Linux / Unix : which command
  6. type Command : Display Information About Command Type On Linux
  7. df command not showing correct free space in linux
  8. How to empty Trash through command line in Ubuntu
  9. awk command to search keyword or strings in file
  10. remove html tags by using sed command

Filed Under: Linux Tagged With: ss

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Forgot root password ,Reset it in Run level 1

send email after mysql backup through bash script in simple way

New XAMPP security concept

rsync all files,hidden files,symlinks,hardlinks to remotes Linux Server

How To Get SSH Public Key Fingerprint Information

How to create a file with cat command

configure: error: C++ compiler cannot create executables

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy