Use the ss Command in Linux to check the socket/network connection

Source: Internet
Author: User

Use the ss Command in Linux to check the socket/network connection

Ss is part of the iproute2 package (a tool for controlling TCP/IP networks and traffic ). Iproute2 is designed to replace the standard Unix network tool set (usually called "net-tools") that was previously used to configure network interfaces, route tables, and manage ARP tables "). The ss tool is used to export socket statistics. It displays information similar to netstat and more TCP and status information. Because it gets information directly from the kernel space, it will be faster. Ss operations are similar to netstat, so it can easily replace netstat.

Usage and common options

Ss is similar to netstat. By default, it displays the list of open non-listener TCP sockets that have established connections. You can use the following options to filter the output:

  • -N-Do not try to parse the service name.
  • -R-try to parse the address/port number.
  • -A-display all sockets.
  • -L-display the listening socket.
  • -P-the process that uses the socket is displayed.
  • -S-print statistics
  • -T-only display TCP sockets.
  • -U-only UDP socket is displayed.
  • -D-only display DCCP socket
  • -W-only displays RAW sockets.
  • -X-only display Unix domain sockets
  • -F FAMILY-displays the type of the FAMILY socket. Currently, the following families are supported: unix, inet, inet6, link, and netlink.
  • -A query-specifies the list of sockets to be listed, which are separated by commas. The following identifiers can be identified: all, inet, tcp, udp, raw, unix, packet, netlink, and unix.Dgram, unixStream, packetRaw, packetDgram.
  • -O STATUS-list sockets in the specified STATUS
Ss Command example

1. display all TCP ports and processes using them:

  1. # Ss-tnap

2. You can use the-4 flag to display IPv4 links and the-6 flag to display IPv6 links. For example:

  1. # Ss-tnap6

3. As with the above behavior, you only need to replace t with u to display all open UDP ports.

  1. # Ss-unap

4. You can use the-s flag to print various useful statistics:

  1. # Ss-s

5. You can use the-o flag to check all links in different States, such as displaying all established connections.

  1. # Ss-tn-o state established-p

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.