Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Network Monitoring Tools»SS Command in Linux (Monitor Network Connections)

    SS Command in Linux (Monitor Network Connections)

    By RahulFebruary 12, 20235 Mins Read

    The ss command is a powerful utility in Linux that allows you to monitor and display information about network sockets. Unlike netstat, ss provides more detailed information and is faster and more efficient. This makes it an essential tool for system administrators and network engineers.

    Advertisement

    In this article, we will discuss the basics of the ss command, its syntax, and some of its key features. We will also cover some advanced usage examples of the ss command to help you get started with this powerful tool.

    ss Command in Linux

    1. Listing All Network Connections
    2. To list all network connections, use the following syntax:

      ss -a 
      

      This command will display a list of all network connections, including those in the LISTEN, ESTABLISHED, and other states. The output of this command will include the source and destination IP addresses, source and destination ports, the protocol (TCP, UDP, etc.), the state of the connection, and other information.

    3. Listing TCP Connections
    4. To list only TCP connections, use the following syntax:

      ss -t 
      

      This command will display a list of all TCP connections, including those in the LISTEN, ESTABLISHED, and other states. The output of this command will include the source and destination IP addresses, source and destination ports, the protocol (TCP), the state of the connection, and other information.

    5. Listing UDP Connections
    6. To list only UDP connections, use the following syntax:

      ss -u 
      

      This command will display a list of all UDP connections. The output of this command will include the source and destination IP addresses, source and destination ports, the protocol (UDP), the state of the connection, and other information.

    7. Filtering Connections by Port
    8. You can filter network connections by port using the following syntax:

      ss -t dst :port 
      

      This command will display a list of all TCP connections with a destination port equal to the specified port. For example, to list all TCP connections with a destination port of 80, you would use the following command:

      ss -t dst :80 
      

    9. Filtering Connections by IP Address
    10. You can filter network connections by IP address using the following syntax:

      ss dst IP_ADDRESS 
      

      This command will display a list of all connections with a destination IP address equal to the specified IP address. For example, to list all connections with a destination IP address of 192.168.1.100, you would use the following command:

      ss dst 192.168.1.100 
      

    11. Displaying Statistics for a Specific Connection
    12. You can display statistics for a specific connection using the following syntax:

      ss -i state IP_ADDRESS:port 
      

      This command will display detailed information about the specified connection, including the state of the connection, the number of packets and bytes sent and received, and other information. For example, to display statistics for a TCP connection with a destination IP address of 192.168.1.100 and a destination port of 80, you would use the following command:

      ss -i state 192.168.1.100:80 
      

    13. Listing Listening Ports
    14. To list listening ports, use the following syntax:

      ss -l 
      

      This command will display a list of all listening ports, including the IP address and port number for each listening socket. The output of this command will also include information about the process

    15. Display All Established TCP Connections
    16. The following command will display all the established TCP connections on the system:

      ss -t state established 
      

    17. Display All Listening Sockets
    18. If you want to see all the listening sockets, you can use the following command:

      ss -l 
      

    19. Display Network Statistics for a Specific Protocol
    20. You can display network statistics for a specific protocol using the following command:

      ss -s protocol 
      

      Replace protocol with the desired protocol (e.g., tcp, udp, etc.).

    21. Display Information for a Specific Port
    22. You can display information for a specific port using the following command:

      ss -t state port 
      

      Replace port with the desired port number.

    23. Display Information for a Specific Remote IP Address
    24. If you want to display information for a specific remote IP address, you can use the following command:

      ss -o src IP_ADDRESS 
      

      Replace IP_ADDRESS with the desired IP address.

    25. Display Information for a Specific Process
    26. You can display information for a specific process using the following command:

      ss -p | grep PID 
      

      Replace PID with the process ID of the desired process.

    27. Display Timestamp Information
    28. You can display the timestamp information of a socket using the following command:

      ss -o time 
      

    29. Display Information for a Specific Socket Buffer
    30. You can display information for a specific socket buffer using the following command:

      ss -o buffer SOCKET_BUFFER 
      

      Replace SOCKET_BUFFER with the desired socket buffer.

    31. Display Information for a Specific Interface
    32. You can display information for a specific interface using the following command:

      ss -i interface 
      

      Replace interface with the desired network interface.

    33. Display Information for a Specific User
    34. You can display information for a specific user using the following command:

      ss -u user 
      

      Replace user with the desired user name.

    Conclusion

    The ss command is a valuable tool for monitoring and analyzing network sockets in Linux. Whether you are a system administrator, network engineer, or simply a Linux enthusiast, having a good understanding of ss can help you diagnose network issues, improve network performance, and optimize your system.

    In conclusion, the ss command is an essential tool for anyone working in a network environment. By using its advanced features and options, you can gain deeper insights into your network and make informed decisions to improve its performance. So, be sure to familiarize yourself with this powerful tool and put it to use in your next Linux project.

    command ss command
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    A Deep Dive into Set Options in Bash

    Check Network Connectivity using Ping Command in Shell Scripts

    How to delete the first N lines from a text file in Linux

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting Up Angular on Ubuntu: Step-by-Step Guide
    • Converting UTC Date and Time to Local Time in Linux
    • Git Restore: Functionality and Practical Examples
    • Git Switch: Functionality and Practical Examples
    • Git Switch vs. Checkout: A Detailed Comparison with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.