Methods for checking network connections using the SS command in Linux

Source: Internet
Author: User
Tags socket

SS is part of the IPROUTE2 package (a tool that controls TCP/IP networks and traffic). The goal of Iproute2 is to replace the standard UNIX Network tool suite (commonly referred to as "Net-tools") previously used to configure network interfaces, routing tables, and administrative ARP tables. The SS tool is used to export socket statistics, which can display information similar to netstat, and can display more TCP and state information. Because it gets information directly from the kernel space, it is faster. SS operates like Netstat, so it makes it easy to replace Netstat.

Usage and common options

SS and Netstat are very similar, and by default it displays a list of open, non-listening TCP sockets that have established connections. And you can filter the output with the following options:

-N-Do not attempt to resolve the service name.

-R-Attempts to resolve the address/port of a number.

-A-displays all sockets.

-L-Displays a listening socket.

-P-Displays the process using this socket.

-S-Print statistical data

-T-displays only TCP sockets.

-U-Displays only UDP sockets.

-D-Show only DCCP sockets

-W-Displays only raw sockets.

-X-only UNIX domain sockets are displayed

-F FAMILY-Displays the type of FAMILY socket. Currently support the following families: Unix, inet, Inet6, Link, netlink.

-A QUERY-Specifies a list of sockets to list, separated by commas. The following identifiers can be identified: All, inet, TCP, UDP, Raw, UNIX, packet, NetLink, Unixdgram, Unixstream, Packetraw, Packetdgram.

-O Status-Lists the sockets for the specified state

SS Command Example

1. Display all of the TCP ports and the processes that use them:

The code is as follows:

# Ss-tnap

2. You can use the 4 logo to display IPv4 links,-6 logos to display IPv6 links, such as:

The code is as follows:


3. As with the above behavior, all you need to do is use u instead of T to display all the open UDP ports.

The code is as follows:

# Ss-unap

4. You can use the-s flag to print a variety of useful statistical data:

The code is as follows:

# ss-s

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

The code is as follows:

# Ss-tn-o State Established-p

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.