Showing posts with label ss. Show all posts
Showing posts with label ss. Show all posts

Wednesday, September 20, 2023

SS command Cheat Sheet

ss Command Cheat Sheet

This cheat sheet provides an overview of the ss command and its commonly used options for examining socket statistics and network connections in Linux. Adjust the options as needed to match your specific requirements when working with ss.

 

1. Displaying Sockets:

  • ss: Display a summary of all sockets.
  • ss -t: Display TCP sockets.
  • ss -u: Display UDP sockets.
  • ss -w: Display raw sockets.
  • ss -x: Display UNIX domain sockets.

 

2. Filtering and Displaying Specific Sockets:

  • ss -tuln: Display all listening TCP and UDP sockets without resolving names.
  • ss -tul: Display all listening TCP and UDP sockets with name resolution.
  • ss -t4: Display IPv4 sockets.
  • ss -t6: Display IPv6 sockets.

 

3. Display Socket Statistics:

  • ss -s: Display socket statistics summary.
  • ss -t -s: Display TCP socket statistics.
  • ss -u -s: Display UDP socket statistics.
  • ss -w -s: Display raw socket statistics.
  • ss -x -s: Display UNIX domain socket statistics.

 

4. Display Extended Information:

  • ss -e: Display extended information, including socket UID and inode.
  • ss -t -a: Display all sockets (listening and non-listening).

 

5. Display Processes Associated with Sockets:

  • ss -t -p: Show the processes associated with each socket.
  • ss -t -t -p: Display TCP sockets along with their associated processes.

 

6. Display Socket Timers:

  • ss -o: Show socket timers (e.g., TCP retransmit timeout).
  • ss -t -o: Display TCP socket timers.
  • ss -u -o: Display UDP socket timers.

 

7. Show Header Information:

  • ss -H: Display header lines to label each column.
  • ss -i: Display information about network interfaces.

 

8. Filter by State:

  • ss state FIN-WAIT-1: Display sockets in a specific state (e.g., FIN-WAIT-1).
  • ss state connected: Show connected sockets.

 

9. Sort Output:

  • ss -t state established -o: Sort and display established TCP connections.
  • ss -n -o state established | sort -r -k 5: Sort established connections by data transfer rate.

 

10. Output in JSON Format:

  • ss -t -j: Display socket information in JSON format.

 

11. Display Help:

  • ss --help: Display the ss command's help and usage information.

 

12. Clear Timers and Counters:

  • ss -t -E: Clear socket timers.
  • ss -t -Z: Clear socket counters.

 

13. Show Reverse DNS Lookups:

  • ss -r: Show reverse DNS lookups in the output.