linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Введение
  • Уроки
  • How it works
  • Симулятор
  • База знаний
  • Собеседование
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Commands/cmd-ss

kb/commands ── Commands ── intermediate

ss: who is listening and who is connected

`ss` is the modern replacement for netstat. It shows sockets in LISTEN and ESTABLISHED state, supports filters by address, port, and state, and provides extended TCP info.

view as markdownaka: socket-statistics

Basic flags

  • -t - TCP
  • -u - UDP
  • -l - listening sockets only
  • -n - do not resolve names or ports (faster; shows raw numbers)
  • -p - show the process (PID and name; requires sudo to see other users' sockets)
  • -a - all sockets (established, listening, and closed)
  • -i - extended TCP info: RTT, cwnd, MSS, retransmits
  • -s - per-protocol summary

Common combinations

bash
ss -tuln                  # all listening TCP/UDP sockets
ss -tnp                    # all TCP sessions with process PID (sudo)
ss -tn state established   # established connections only
ss -tn state time-wait | wc -l   # count TIME_WAIT sockets (see [[tcp-states]])
ss -tnli                   # listening sockets with extended info

Filters by address and port

bash
ss -tn '( dport = 443 or sport = 443 )'
ss -tn dst 8.8.8.8
ss -tn src 10.0.0.5/24

You can also use dport > 1024, sport != 80, and similar expressions.

ss -ti: inside a TCP session

The most useful command when debugging performance:

bash
ss -ti dst 1.2.3.4
# ESTAB ... 192.168.1.10:54321  1.2.3.4:443
#   cubic wscale:7,7 rto:212 rtt:10.5/2.5 ato:40 mss:1448
#   pacing_rate 12.3Mbps delivery_rate 11.8Mbps app_limited
#   sndbuf=87040 rcvbuf=131072 retrans:0/0 ...

Key fields:

  • cubic / bbr - congestion control algorithm
  • rtt - measured round-trip time (mean / mdev)
  • rto - retransmit timeout
  • mss - max segment size
  • cwnd - congestion window (reflected in pacing_rate)
  • retrans - cur/total: retransmits currently in flight / total. A high value points to packet loss on the path.

Replacing netstat

Old commands and their equivalents:

netstatss
netstat -tulnss -tuln
netstat -tnpss -tnp (with sudo)
netstat -sss -s

ss is faster (uses the netlink API directly, with less /proc parsing) and shows more detail. On modern distributions, netstat is not installed at all.

§ команды

bash
ss -tuln

All listening TCP/UDP sockets, without name resolution

bash
sudo ss -tnp

All TCP sessions with PID and process name (without sudo, other users' sockets are hidden)

bash
ss -tn state time-wait | wc -l

Count of TIME_WAIT sockets. This number can grow on services with short-lived connections.

bash
ss -ti dst 1.2.3.4

TCP session details: RTT, cwnd, retransmits, congestion algorithm

bash
ss -K dst 1.2.3.4 dport = 8080

Force-close (RST) matching sockets. Use as a last resort.

§ см. также

  • tcp-handshakeTCP three-way handshakeTCP connection opens with three packets: SYN from the client, SYN-ACK from the server, ACK from the client. After that the connection is Established and data transfer can begin.
  • tcp-statesTCP states (LISTEN, ESTABLISHED, TIME_WAIT)A TCP session moves through 11 states from LISTEN to CLOSED. The most important in production: LISTEN, ESTABLISHED, TIME_WAIT, CLOSE_WAIT.
  • cmd-ipip: Swiss army knife for network configuration`ip` is the iproute2 frontend that replaces the old ifconfig, route, and arp tools. Subcommands: `ip addr` (addresses), `ip link` (interfaces), `ip route` (routing table), `ip neigh` (ARP).

§ упоминается в уроках

  • ›advanced-04-tcp-tuning
  • ›advanced-05-bandwidth-iperf
  • ›intermediate-01-network-101
  • ›intermediate-07-debugging-with-proc
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies