The ss command (Socket Statistics) is a powerful command-line utility used in Linux to dump socket statistics and display detailed network connection information. It serves as the modern, high-performance replacement for the deprecated netstat command because it interacts directly with the Linux kernel via the netlink interface instead of slowly parsing /proc files. [1, 2, 3, 4]
Essential Syntax & Common Flags
-t: Restricts the output to TCP sockets.-u: Restricts the output to UDP sockets.-l: Shows only listening sockets (ports waiting for traffic).-a: Shows all sockets, combining both listening and non-listening connections.-n: Displays numerical IP addresses and ports instead of resolving them into hostnames or service names (e.g.,22instead ofssh), which significantly speeds up execution.
Practical Examples for Common Tasks
1. See All Listening Services (The "Swiss Army Knife" Command)
To inspect every service actively listening on your machine along with its process name and raw port number, execute:
bash
sudo ss -tulpn
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
2. Find What Process is Using a Specific Port
bash
sudo ss -tulpn sport = :8080
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
3. View Only Active, Established Connections [1]
bash
ss -at state established
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
4. Get a Quick Network Health Check [1]
bash
ss -s
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
Understanding the Output Columns
When you run a standard query,
ss outputs data organized into columns: [1]- Netid: The protocol type (e.g.,
tcp,udp, or local file-basedu_strUnix sockets). - State: The connection lifecycle state (e.g.,
ESTABfor active connections,LISTENfor services awaiting traffic). - Recv-Q / Send-Q: The queue size in bytes. For an active socket, non-zero or growing values mean data is getting backed up or delayed in transit.
- Local Address:Port: The local IP address and port binding of your machine.
For further advanced options like connection timers or specific IPv4/IPv6 isolation, you can consult the official documentation on the man7.org ss manual page. [1]
What specific networking problem or port issue are you trying to troubleshoot on your Linux system right now?
No comments:
Post a Comment