<!DOCTYPE html>
<html lang="zh-Hans">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=5">
    <title>How To Use Linux SS Command | 云图网</title>
    <meta name="description" content="Introduction The ss (socket statistics) tool is a CLI command used to show network statistics. The ss command is a simpler and faster version of the now obsolet…">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.ytso.com/tech/aiops/224303.html">
<meta property="og:site_name" content="云图网">
<meta property="og:title" content="How To Use Linux SS Command">
<meta property="og:image" content="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111210510.png">
<meta property="og:description" content="Introduction The ss (socket statistics) tool is a CLI command used to show network statistics. The ss command is a simpler and faster version of the now obsolet…">
<link rel="canonical" href="https://blog.ytso.com/tech/aiops/224303.html">
<meta name="applicable-device" content="pc,mobile">
<meta http-equiv="Cache-Control" content="no-transform">
<link rel="shortcut icon" href="https://imgcdn.ytso.com/wp-content/uploads/2024/10/20241015181503433.jpg">
<link rel='dns-prefetch' href='//cdnjs.cloudflare.com' />
<style id='wp-img-auto-sizes-contain-inline-css' type='text/css'>
img:is([sizes=auto i],[sizes^="auto," i]){contain-intrinsic-size:3000px 1500px}
/*# sourceURL=wp-img-auto-sizes-contain-inline-css */
</style>
<link rel='stylesheet' id='stylesheet-css' href='https://blog.ytso.com/wp-content/themes/justnews/css/style.css?ver=6.21.5' type='text/css' media='all' />
<link rel='stylesheet' id='material-icons-css' href='https://blog.ytso.com/wp-content/themes/justnews/themer/assets/css/material-icons.css?ver=6.21.5' type='text/css' media='all' />
<link rel='stylesheet' id='remixicon-css' href='https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.2.0/remixicon.min.css?ver=6.9.4' type='text/css' media='all' />
<link rel='stylesheet' id='font-awesome-css' href='https://blog.ytso.com/wp-content/themes/justnews/themer/assets/css/font-awesome.css?ver=6.21.5' type='text/css' media='all' />
<style id='wp-block-library-inline-css' type='text/css'>
:root{--wp-block-synced-color:#7a00df;--wp-block-synced-color--rgb:122,0,223;--wp-bound-block-color:var(--wp-block-synced-color);--wp-editor-canvas-background:#ddd;--wp-admin-theme-color:#007cba;--wp-admin-theme-color--rgb:0,124,186;--wp-admin-theme-color-darker-10:#006ba1;--wp-admin-theme-color-darker-10--rgb:0,107,160.5;--wp-admin-theme-color-darker-20:#005a87;--wp-admin-theme-color-darker-20--rgb:0,90,135;--wp-admin-border-width-focus:2px}@media (min-resolution:192dpi){:root{--wp-admin-border-width-focus:1.5px}}.wp-element-button{cursor:pointer}:root .has-very-light-gray-background-color{background-color:#eee}:root .has-very-dark-gray-background-color{background-color:#313131}:root .has-very-light-gray-color{color:#eee}:root .has-very-dark-gray-color{color:#313131}:root .has-vivid-green-cyan-to-vivid-cyan-blue-gradient-background{background:linear-gradient(135deg,#00d084,#0693e3)}:root .has-purple-crush-gradient-background{background:linear-gradient(135deg,#34e2e4,#4721fb 50%,#ab1dfe)}:root .has-hazy-dawn-gradient-background{background:linear-gradient(135deg,#faaca8,#dad0ec)}:root .has-subdued-olive-gradient-background{background:linear-gradient(135deg,#fafae1,#67a671)}:root .has-atomic-cream-gradient-background{background:linear-gradient(135deg,#fdd79a,#004a59)}:root .has-nightshade-gradient-background{background:linear-gradient(135deg,#330968,#31cdcf)}:root .has-midnight-gradient-background{background:linear-gradient(135deg,#020381,#2874fc)}:root{--wp--preset--font-size--normal:16px;--wp--preset--font-size--huge:42px}.has-regular-font-size{font-size:1em}.has-larger-font-size{font-size:2.625em}.has-normal-font-size{font-size:var(--wp--preset--font-size--normal)}.has-huge-font-size{font-size:var(--wp--preset--font-size--huge)}.has-text-align-center{text-align:center}.has-text-align-left{text-align:left}.has-text-align-right{text-align:right}.has-fit-text{white-space:nowrap!important}#end-resizable-editor-section{display:none}.aligncenter{clear:both}.items-justified-left{justify-content:flex-start}.items-justified-center{justify-content:center}.items-justified-right{justify-content:flex-end}.items-justified-space-between{justify-content:space-between}.screen-reader-text{border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}.screen-reader-text:focus{background-color:#ddd;clip-path:none;color:#444;display:block;font-size:1em;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000}html :where(.has-border-color){border-style:solid}html :where([style*=border-top-color]){border-top-style:solid}html :where([style*=border-right-color]){border-right-style:solid}html :where([style*=border-bottom-color]){border-bottom-style:solid}html :where([style*=border-left-color]){border-left-style:solid}html :where([style*=border-width]){border-style:solid}html :where([style*=border-top-width]){border-top-style:solid}html :where([style*=border-right-width]){border-right-style:solid}html :where([style*=border-bottom-width]){border-bottom-style:solid}html :where([style*=border-left-width]){border-left-style:solid}html :where(img[class*=wp-image-]){height:auto;max-width:100%}:where(figure){margin:0 0 1em}html :where(.is-position-sticky){--wp-admin--admin-bar--position-offset:var(--wp-admin--admin-bar--height,0px)}@media screen and (max-width:600px){html :where(.is-position-sticky){--wp-admin--admin-bar--position-offset:0px}}
/*wp_block_styles_on_demand_placeholder:69cb887f92de0*/
/*# sourceURL=wp-block-library-inline-css */
</style>
<style id='classic-theme-styles-inline-css' type='text/css'>
/*! This file is auto-generated */
.wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
/*# sourceURL=/wp-includes/css/classic-themes.min.css */
</style>
<link rel='stylesheet' id='wpcom-member-css' href='https://blog.ytso.com/wp-content/plugins/wpcom-member/css/style.css?ver=1.7.19' type='text/css' media='all' />
<script type="text/javascript" src="https://blog.ytso.com/wp-includes/js/jquery/jquery.min.js?ver=3.7.1" id="jquery-core-js"></script>
<script type="text/javascript" src="https://blog.ytso.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1" id="jquery-migrate-js"></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://blog.ytso.com/xmlrpc.php?rsd" />
<meta name='description' content='Introduction The ss (socket statistics) tool is a CLI command used to show network statistics. The ss command is a simpler and faster version of the now obsolete netstat command. Together with the ip…' />
<style>:root{--theme-color: #08c; --theme-hover: #07c; --logo-height: 32px; --logo-height-mobile: 26px; --menu-item-gap: 28px; --member-login-bg: url('https://blog.ytso.com/loginwall.jpg'); --header-bg-color: #fff; --header-bg-image: none; --theme-border-radius-s: 3px; --theme-border-radius-m: 5px; --theme-border-radius-l: 8px; --theme-border-radius-xl: 12px; --thumb-ratio-default: 480 / 300; --thumb-ratio-post: 480 / 300; --post-video-ratio: 860 / 482;}</style>
<link rel="icon" href="https://imgcdn.ytso.com/wp-content/uploads/2024/10/20241015181503433.jpg" sizes="32x32" />
<link rel="icon" href="https://imgcdn.ytso.com/wp-content/uploads/2024/10/20241015181503433.jpg" sizes="192x192" />
<link rel="apple-touch-icon" href="https://imgcdn.ytso.com/wp-content/uploads/2024/10/20241015181503433.jpg" />
<meta name="msapplication-TileImage" content="https://imgcdn.ytso.com/wp-content/uploads/2024/10/20241015181503433.jpg" />
    <!--[if lte IE 11]><script src="https://blog.ytso.com/wp-content/themes/justnews/js/update.js"></script><![endif]-->
</head>
<body class="wp-singular post-template-default single single-post postid-224303 single-format-standard wp-theme-justnews lang-cn el-boxed header-fixed">
<header class="header header-fluid">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse" aria-label="menu">
                <span class="icon-bar icon-bar-1"></span>
                <span class="icon-bar icon-bar-2"></span>
                <span class="icon-bar icon-bar-3"></span>
            </button>
                        <div class="logo">
                <a href="https://blog.ytso.com/" rel="home">
                    <img src="https://imgcdn.ytso.com/wp-content/uploads/2021/12/20211207181156143.png" alt="云图网">
                </a>
            </div>
        </div>
        <div class="collapse navbar-collapse mobile-style-0">
            <nav class="primary-menu"><ul id="menu-justnews-footer-menu" class="nav navbar-nav wpcom-adv-menu"><li class="menu-item"><a href="https://blog.ytso.com/category/industrynews">业界资讯</a></li>
<li class="menu-item current-post-ancestor active menu-item-style menu-item-style-1 dropdown"><a target="_blank" href="https://blog.ytso.com/category/tech" class="dropdown-toggle">技术专区</a>
<ul class="dropdown-menu menu-item-wrap menu-item-col-5">
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/cloud">云计算</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/ai">人工智能</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/safety">信息安全</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/bigdata">大数据</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/dev">研发管理</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/webdev">大前端</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/opensource">开源</a></li>
	<li class="menu-item current-post-ancestor current-post-parent active"><a href="https://blog.ytso.com/category/tech/aiops">智能运维</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/pnotes">编程笔记</a></li>
	<li class="menu-item"><a href="https://blog.ytso.com/category/tech/wp">WordPress</a></li>
</ul>
</li>
<li class="menu-item"><a href="https://blog.ytso.com/category/enterprise-strategic-planning">企业战略规划</a></li>
<li class="menu-item"><a href="https://blog.ytso.com/category/download">下载专区</a></li>
<li class="menu-item"><a href="https://blog.ytso.com/category/it%e6%b1%9f%e6%b9%96%e5%8f%b2">江湖史</a></li>
<li class="menu-item"><a href="https://blog.ytso.com/category/notes">随笔记录</a></li>
</ul></nav>            <div class="navbar-action">
                <div class="navbar-search-icon j-navbar-search"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-search"></use></svg></i></div><form class="navbar-search" action="https://blog.ytso.com/" method="get" role="search"><div class="navbar-search-inner"><i class="wpcom-icon wi navbar-search-close"><svg aria-hidden="true"><use xlink:href="#wi-close"></use></svg></i><input type="text" name="s" class="navbar-search-input" autocomplete="off" maxlength="100" placeholder="输入关键词搜索..." value=""><button class="navbar-search-btn" type="submit" aria-label="搜索"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-search"></use></svg></i></button></div></form>                    <div id="j-user-wrap">
                        <a class="login" href="https://blog.ytso.com/login">登录</a>
                        <a class="login register" href="https://blog.ytso.com/register">注册</a>
                    </div>
                                            <a class="wpcom-btn btn-primary btn-xs publish" href="https://blog.ytso.com/contribute">
                            <i class="fa fa-edit"></i> 投稿                        </a>
                                </div>
        </div>
    </div><!-- /.container -->
</header>

<div id="wrap">    <div class="wrap container">
        <ol class="breadcrumb" vocab="https://schema.org/" typeof="BreadcrumbList"><li class="home" property="itemListElement" typeof="ListItem"><a href="https://blog.ytso.com" property="item" typeof="WebPage"><span property="name" class="hide">云图网</span>首页</a><meta property="position" content="1"></li><li property="itemListElement" typeof="ListItem"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-arrow-right-3"></use></svg></i><a href="https://blog.ytso.com/category/tech" property="item" typeof="WebPage"><span property="name">技术专区</span></a><meta property="position" content="2"></li><li property="itemListElement" typeof="ListItem"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-arrow-right-3"></use></svg></i><a href="https://blog.ytso.com/category/tech/aiops" property="item" typeof="WebPage"><span property="name">智能运维</span></a><meta property="position" content="3"></li></ol>        <main class="main">
                            <article id="post-224303" class="post-224303 post type-post status-publish format-standard hentry category-aiops entry">
                    <div class="entry-main">
                                                                        <div class="entry-head">
                            <h1 class="entry-title">How To Use Linux SS Command</h1>
                            <div class="entry-info">
                                                                <time class="entry-date published" datetime="2022-01-07T11:11:26+08:00" pubdate>
                                    2022年1月7日 11:11                                </time>
                                <span class="dot">•</span>
                                <a href="https://blog.ytso.com/category/tech/aiops" rel="category tag">智能运维</a>                                                            </div>
                        </div>
                        
                                                <div class="entry-content text-indent text-justify">
                            <div id="toc">
<p class="toc-title"><strong>文章目录</strong><span class="toc-controller toc-controller-show">[隐藏]</span></p>
<ul>
<li class="toc-level2"><a href="#ftoc-heading-1">Linux ss Command Examples</a>
<ul>
<li class="toc-level3"><a href="#ftoc-heading-2">List All Connections</a></li>
<li class="toc-level3"><a href="#ftoc-heading-3">List Listening Sockets</a></li>
<li class="toc-level3"><a href="#ftoc-heading-4">List TCP Connections</a></li>
<li class="toc-level3"><a href="#ftoc-heading-5">List UDP Connections</a></li>
<li class="toc-level3"><a href="#ftoc-heading-6">List Unix Sockets</a></li>
<li class="toc-level3"><a href="#ftoc-heading-7">List Raw Sockets</a></li>
<li class="toc-level3"><a href="#ftoc-heading-8">List Connections to a Specific IP Address</a></li>
<li class="toc-level3"><a href="#ftoc-heading-9">Check Process IDs</a></li>
<li class="toc-level3"><a href="#ftoc-heading-10">List Summary Statistics</a></li>
<li class="toc-level3"><a href="#ftoc-heading-11">List IPv4 and IPv6 Socket Connections</a></li>
<li class="toc-level3"><a href="#ftoc-heading-12">Filter Connections</a></li>
<li class="toc-level3"><a href="#ftoc-heading-13">Check Man Pages or List All Commands</a></li>
</ul>
</li>
<li class="toc-level2"><a href="#ftoc-heading-14">netstat VS ss Command</a></li>
</ul>
</div>
<p class="h3">Introduction</p>
<p>The ss (socket statistics) tool is a CLI command used to show network statistics. The <strong>ss</strong> command is a simpler and faster version of the now obsolete <a href="https://phoenixnap.com/kb/netstat-command" target="_blank" rel="noreferrer noopener">netstat command</a>. Together with the <a href="https://phoenixnap.com/kb/linux-ip-command-examples" target="_blank" rel="noreferrer noopener">ip command</a>, <strong>ss</strong> is essential for gathering network information and troubleshooting network issues.</p>
<p><strong>This article gives an overview of how to use the ss command and shows examples of the most common use cases.</strong></p>
<div class="wp-block-image"><noscript><img fetchpriority="high" decoding="async" width="800" height="400" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111210510.png" alt="How to Use the ss Command in Linux" class="wp-image-101999" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/How-to-Use-the-ss-Command-in-Linux.png"/></noscript><img fetchpriority="high" decoding="async" width="800" height="400" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111210510.png" alt="How to Use the ss Command in Linux" class="wp-image-101999 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/How-to-Use-the-ss-Command-in-Linux.png"/><noscript><noscript><img decoding="async" width="800" height="400" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111210510.png" alt="How to Use the ss Command in Linux" class="wp-image-101999"/></noscript><img decoding="async" width="800" height="400" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111210510.png" alt="How to Use the ss Command in Linux" class="wp-image-101999 j-lazy"/></noscript></div>
<p class="h3">Prerequisites</p>
<ul>
<li>Access to a terminal or command line</li>
<li>Installed iproute2 software package</li>
</ul>
<div class="notice-note">
<div class="note-icon-wrapper"><i class="fa fa-lightbulb"></i></div>
<div class="notice-text">
<p><strong>Note:</strong> Use the <a href="https://phoenixnap.com/kb/how-to-use-apt-get-commands" target="_blank" rel="noopener">apt-get</a> commands to install, update or upgrade the iproute2 software package.</p>
</div>
</div>
<h2 class="ftwp-heading" id="ftoc-heading-1">Linux ss Command Examples</h2>
<p>The basic <strong><code>ss</code></strong> command usage is without any parameters:</p>
<pre class="wp-block-code"><code>ss</code></pre>
<p>The output returns a list of open non-listening sockets with established connections.</p>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111212834.png" alt="Terminal output of the command ss" class="wp-image-102002" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-command-example.png"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111212834.png" alt="Terminal output of the command ss" class="wp-image-102002 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111212834.png" alt="Terminal output of the command ss" class="wp-image-102002"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111212834.png" alt="Terminal output of the command ss" class="wp-image-102002 j-lazy"/></noscript></div>
<p>The columns show the following details:</p>
<ul>
<li><strong>Netid</strong> – Type of socket. Common types are <em>TCP</em>, <em>UDP</em>, <em>u_str</em> (Unix stream), and <em>u_seq</em> (Unix sequence).</li>
<li><strong>State</strong> – State of the socket. Most commonly <em>ESTAB</em> (established), <em>UNCONN</em> (unconnected), <em>LISTEN</em> (listening).</li>
<li><strong>Recv-Q </strong>– Number of received packets in the queue.</li>
<li><strong>Send-Q</strong> – Number of sent packets in the queue.</li>
<li><strong>Local address:port </strong>– Address of local machine and port.</li>
<li><strong>Peer address:port</strong> – Address of remote machine and port.</li>
</ul>
<p>For a more detailed output, add options to the <strong><code>ss</code></strong> command:</p>
<pre class="wp-block-code"><code>ss &lt;options&gt;</code></pre>
<p>Or list the options individually:</p>
<pre class="wp-block-code"><code>ss &lt;option 1&gt; &lt;option 2&gt; &lt;option 3&gt;</code></pre>
<div class="notice-note">
<div class="note-icon-wrapper"><i class="fa fa-lightbulb"></i></div>
<div class="notice-text">
<p><strong>Note:</strong> There are many Linux CLI tools for <a href="https://phoenixnap.com/kb/linux-network-speed-test" target="_blank" rel="noopener">testing the network speed</a> if the connection is slow.</p>
</div>
</div>
<h3 class="ftwp-heading" id="ftoc-heading-2">List All Connections</h3>
<p>List all listening and non-listening connections with:</p>
<pre class="wp-block-code"><code>ss -a</code></pre>
<p>Or:</p>
<pre class="wp-block-code"><code>ss --all</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111213914.png" alt="Terminal output of the command ss -a command" class="wp-image-102003" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-a-command-example.png"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111213914.png" alt="Terminal output of the command ss -a command" class="wp-image-102003 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-a-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111213914.png" alt="Terminal output of the command ss -a command" class="wp-image-102003"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111213914.png" alt="Terminal output of the command ss -a command" class="wp-image-102003 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-3">List Listening Sockets</h3>
<p>To display only listening sockets, which are omitted by default, use:</p>
<pre class="wp-block-code"><code>ss -l</code></pre>
<p>Or:</p>
<pre class="wp-block-code"><code>ss --listen</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111215538.png" alt="Terminal output of the command ss -l" class="wp-image-102004" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-l-command-example.png"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111215538.png" alt="Terminal output of the command ss -l" class="wp-image-102004 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-l-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111215538.png" alt="Terminal output of the command ss -l" class="wp-image-102004"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111215538.png" alt="Terminal output of the command ss -l" class="wp-image-102004 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-4">List TCP Connections</h3>
<p>To list TCP connections, add the <strong><code>-t</code></strong> option to the <strong><code>ss</code></strong> command:</p>
<pre class="wp-block-code"><code>ss -t</code></pre>
<p>Alternatively:</p>
<pre class="wp-block-code"><code>ss --tcp</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="799" height="90" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111217258.png" alt="Terminal output of the command ss -t" class="wp-image-102005" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-t-command-example.png"/></noscript><img decoding="async" width="799" height="90" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111217258.png" alt="Terminal output of the command ss -t" class="wp-image-102005 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-t-command-example.png"/><noscript><noscript><img decoding="async" width="799" height="90" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111217258.png" alt="Terminal output of the command ss -t" class="wp-image-102005"/></noscript><img decoding="async" width="799" height="90" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111217258.png" alt="Terminal output of the command ss -t" class="wp-image-102005 j-lazy"/></noscript></div>
<p><strong>List All TCP Connections</strong></p>
<p>Combine the options <strong><code>-a</code></strong> and <strong><code>-t</code></strong> with the <strong><code>ss</code></strong> command to output a list of all the TCP connections:</p>
<pre class="wp-block-code"><code>ss -at</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111218148.png" alt="Terminal output of the command ss -at" class="wp-image-102008" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-at-command-example.png"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111218148.png" alt="Terminal output of the command ss -at" class="wp-image-102008 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-at-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="160" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111218148.png" alt="Terminal output of the command ss -at" class="wp-image-102008"/></noscript><img decoding="async" width="800" height="160" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111218148.png" alt="Terminal output of the command ss -at" class="wp-image-102008 j-lazy"/></noscript></div>
<p><strong>List All Listening TCP Connections</strong></p>
<p>Combine the options <strong><code>-l</code></strong> and <strong><code>-t</code></strong> with the <strong><code>ss</code></strong> command to list all listening TCP connections:</p>
<pre class="wp-block-code"><code>ss -lt</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="120" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111221385.png" alt="Terminal output of the command ss -lt" class="wp-image-102009" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-lt-command-example.png"/></noscript><img decoding="async" width="800" height="120" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111221385.png" alt="Terminal output of the command ss -lt" class="wp-image-102009 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-lt-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="120" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111221385.png" alt="Terminal output of the command ss -lt" class="wp-image-102009"/></noscript><img decoding="async" width="800" height="120" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111221385.png" alt="Terminal output of the command ss -lt" class="wp-image-102009 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-5">List UDP Connections</h3>
<p>To show a list of UDP connections, use:</p>
<pre class="wp-block-code"><code>ss -u</code></pre>
<p>Or:</p>
<pre class="wp-block-code"><code>ss --udp</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111222815.png" alt="Terminal output of the command ss -u" class="wp-image-102013" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-u-command-example.png"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111222815.png" alt="Terminal output of the command ss -u" class="wp-image-102013 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-u-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111222815.png" alt="Terminal output of the command ss -u" class="wp-image-102013"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111222815.png" alt="Terminal output of the command ss -u" class="wp-image-102013 j-lazy"/></noscript></div>
<p><strong>List All UDP Connections</strong></p>
<p>Combining the options <strong><code>-a</code></strong> and <strong><code>-u</code></strong> with <strong><code>ss</code></strong> outputs a list of all the TCP connections:</p>
<pre class="wp-block-code"><code>ss -au</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="240" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111224316.png" alt="Terminal output of the command ss -au" class="wp-image-102011" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-au-command-example.png"/></noscript><img decoding="async" width="800" height="240" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111224316.png" alt="Terminal output of the command ss -au" class="wp-image-102011 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-au-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="240" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111224316.png" alt="Terminal output of the command ss -au" class="wp-image-102011"/></noscript><img decoding="async" width="800" height="240" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111224316.png" alt="Terminal output of the command ss -au" class="wp-image-102011 j-lazy"/></noscript></div>
<p><strong>List All Listening UDP Connections</strong></p>
<p>To list all listening UDP connections, use the <strong><code>ss</code></strong> command with options <strong><code>-l</code></strong> and <strong><code>-u</code></strong>:</p>
<pre class="wp-block-code"><code>ss -lu</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="235" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111226947.png" alt="Terminal output of the command ss -lu" class="wp-image-102012" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-lu-command-example.png"/></noscript><img decoding="async" width="800" height="235" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111226947.png" alt="Terminal output of the command ss -lu" class="wp-image-102012 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-lu-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="235" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111226947.png" alt="Terminal output of the command ss -lu" class="wp-image-102012"/></noscript><img decoding="async" width="800" height="235" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111226947.png" alt="Terminal output of the command ss -lu" class="wp-image-102012 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-6">List Unix Sockets</h3>
<p>To show all the Unix family sockets, use:</p>
<pre class="wp-block-code"><code>ss -f unix</code></pre>
<p>Or use the shorter alias:</p>
<pre class="wp-block-code"><code>ss -x</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="175" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111229487.png" alt="Terminal output of the command ss -x" class="wp-image-102015" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-x-command-example.png"/></noscript><img decoding="async" width="800" height="175" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111229487.png" alt="Terminal output of the command ss -x" class="wp-image-102015 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-x-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="175" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111229487.png" alt="Terminal output of the command ss -x" class="wp-image-102015"/></noscript><img decoding="async" width="800" height="175" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111229487.png" alt="Terminal output of the command ss -x" class="wp-image-102015 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-7">List Raw Sockets</h3>
<p>To list raw sockets, use:</p>
<pre class="wp-block-code"><code>ss -w</code></pre>
<p>Or alternatively:</p>
<pre class="wp-block-code"><code>ss --raw</code></pre>
<h3 class="ftwp-heading" id="ftoc-heading-8">List Connections to a Specific IP Address</h3>
<p>List connections to a specific destination IP address with:</p>
<pre class="wp-block-code"><code>ss dst &lt;address&gt;</code></pre>
<p>For example:</p>
<pre class="wp-block-code"><code>ss dst 104.21.3.132</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111232586.png" alt="Terminal output of the command ss dst address" class="wp-image-102016" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-address-command-example.png"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111232586.png" alt="Terminal output of the command ss dst address" class="wp-image-102016 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-address-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111232586.png" alt="Terminal output of the command ss dst address" class="wp-image-102016"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111232586.png" alt="Terminal output of the command ss dst address" class="wp-image-102016 j-lazy"/></noscript></div>
<p>To show connections to a specific source address, use:</p>
<pre class="wp-block-code"><code>ss src &lt;addresss&gt;</code></pre>
<p>For example:</p>
<pre class="wp-block-code"><code>ss src 192.168.100.2</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="100" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111251805.png" alt="Terminal output of the command ss src address" class="wp-image-102017" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-src-address-command-example.png"/></noscript><img decoding="async" width="800" height="100" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111251805.png" alt="Terminal output of the command ss src address" class="wp-image-102017 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-src-address-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="100" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111251805.png" alt="Terminal output of the command ss src address" class="wp-image-102017"/></noscript><img decoding="async" width="800" height="100" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111251805.png" alt="Terminal output of the command ss src address" class="wp-image-102017 j-lazy"/></noscript></div>
<div class="notice-note">
<div class="note-icon-wrapper"><i class="fa fa-lightbulb"></i></div>
<div class="notice-text">
<p><strong>Note:</strong> To show all connections to the local machine, check <a href="https://phoenixnap.com/kb/how-to-find-ip-address-linux" target="_blank" rel="noopener">your IP address</a> and add the ss src command.</p>
</div>
</div>
<h3 class="ftwp-heading" id="ftoc-heading-9">Check Process IDs</h3>
<p>To show process IDs (PID), use:</p>
<pre class="wp-block-code"><code>ss -p</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="140" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111252199.png" alt="Terminal output of the command ss -p" class="wp-image-102020" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-p-command-example.png"/></noscript><img decoding="async" width="800" height="140" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111252199.png" alt="Terminal output of the command ss -p" class="wp-image-102020 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-p-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="140" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111252199.png" alt="Terminal output of the command ss -p" class="wp-image-102020"/></noscript><img decoding="async" width="800" height="140" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111252199.png" alt="Terminal output of the command ss -p" class="wp-image-102020 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-10">List Summary Statistics</h3>
<p>List the summary statistics for connections with:</p>
<pre class="wp-block-code"><code>ss -s</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="180" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111255103.png" alt="Terminal output of the command ss -s" class="wp-image-102022" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-s-command-example.png"/></noscript><img decoding="async" width="800" height="180" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111255103.png" alt="Terminal output of the command ss -s" class="wp-image-102022 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-s-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="180" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111255103.png" alt="Terminal output of the command ss -s" class="wp-image-102022"/></noscript><img decoding="async" width="800" height="180" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111255103.png" alt="Terminal output of the command ss -s" class="wp-image-102022 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-11">List IPv4 and IPv6 Socket Connections</h3>
<p>Filter results further by listing <a href="https://phoenixnap.com/blog/ipv4-vs-ipv6" target="_blank" rel="noreferrer noopener">IPv4/IPv6</a> connections with:</p>
<pre class="wp-block-code"><code>ss -4</code></pre>
<p>Or:</p>
<pre class="wp-block-code"><code>ss -6</code></pre>
<p>For example, list all IPv6 UDP connections with:</p>
<pre class="wp-block-code"><code>ss -au6</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="150" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111257513.png" alt="Terminal output of the command ss -au6" class="wp-image-102024" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-au6-command-example.png"/></noscript><img decoding="async" width="800" height="150" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111257513.png" alt="Terminal output of the command ss -au6" class="wp-image-102024 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-au6-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="150" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111257513.png" alt="Terminal output of the command ss -au6" class="wp-image-102024"/></noscript><img decoding="async" width="800" height="150" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111257513.png" alt="Terminal output of the command ss -au6" class="wp-image-102024 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-12">Filter Connections</h3>
<p>The <strong><code>ss</code></strong> command allows advanced filtering of results and searching for specific ports or TCP states.</p>
<p><strong>Filter Using TCP States</strong></p>
<p>Filter TCP connections using the TCP predefined states:</p>
<pre class="wp-block-code"><code>ss state &lt;name of state&gt;</code></pre>
<p>For example, to find all listening TCP connections:</p>
<pre class="wp-block-code"><code>ss -t state listening</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="120" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111258154.png" alt="Terminal output of the command ss -t state listening" class="wp-image-102025" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-t-state-listening-command-example.png"/></noscript><img decoding="async" width="800" height="120" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111258154.png" alt="Terminal output of the command ss -t state listening" class="wp-image-102025 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-t-state-listening-command-example.png"/><noscript><noscript><img decoding="async" width="800" height="120" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111258154.png" alt="Terminal output of the command ss -t state listening" class="wp-image-102025"/></noscript><img decoding="async" width="800" height="120" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111258154.png" alt="Terminal output of the command ss -t state listening" class="wp-image-102025 j-lazy"/></noscript></div>
<p><strong>Filter by Port Number</strong></p>
<p>Filter for a specific destination port number or port name:</p>
<pre class="wp-block-code"><code>ss &lt;options&gt; dst :&lt;port number or name&gt;</code></pre>
<p>For example:</p>
<pre class="wp-block-code"><code>ss dst :5228</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111300477.png" alt="Terminal output of the command ss dst port number" class="wp-image-102028" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-port-number-example.png"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111300477.png" alt="Terminal output of the command ss dst port number" class="wp-image-102028 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-port-number-example.png"/><noscript><noscript><img decoding="async" width="800" height="60" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111300477.png" alt="Terminal output of the command ss dst port number" class="wp-image-102028"/></noscript><img decoding="async" width="800" height="60" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111300477.png" alt="Terminal output of the command ss dst port number" class="wp-image-102028 j-lazy"/></noscript></div>
<p>Or use a port name:</p>
<pre class="wp-block-code"><code>ss dst :https</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="130" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111302101.png" alt="Terminal output of the command ss dst port name" class="wp-image-102027" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-port-name-example.png"/></noscript><img decoding="async" width="800" height="130" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111302101.png" alt="Terminal output of the command ss dst port name" class="wp-image-102027 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-dst-port-name-example.png"/><noscript><noscript><img decoding="async" width="800" height="130" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111302101.png" alt="Terminal output of the command ss dst port name" class="wp-image-102027"/></noscript><img decoding="async" width="800" height="130" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111302101.png" alt="Terminal output of the command ss dst port name" class="wp-image-102027 j-lazy"/></noscript></div>
<p>Combine multiple queries for more advanced filtering. For example, find all connections with a destination port <em>5228</em> or source port <em>mysql</em>:</p>
<pre class="wp-block-code"><code>ss -a dst :5228 or src :mysql</code></pre>
<div class="wp-block-image"><noscript><img decoding="async" width="800" height="80" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111304383.png" alt="Terminal output of the command ss command advanced search" class="wp-image-102026" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-command-advanced-search-example.png"/></noscript><img decoding="async" width="800" height="80" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111304383.png" alt="Terminal output of the command ss command advanced search" class="wp-image-102026 j-lazy" data-lazy-src="https://phoenixnap.com/kb/wp-content/uploads/2021/04/ss-command-advanced-search-example.png"/><noscript><noscript><img decoding="async" width="800" height="80" src="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111304383.png" alt="Terminal output of the command ss command advanced search" class="wp-image-102026"/></noscript><img decoding="async" width="800" height="80" src="https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111304383.png" alt="Terminal output of the command ss command advanced search" class="wp-image-102026 j-lazy"/></noscript></div>
<h3 class="ftwp-heading" id="ftoc-heading-13">Check Man Pages or List All Commands</h3>
<p>Check the <a href="https://phoenixnap.com/kb/linux-man" target="_blank" rel="noreferrer noopener">manual page</a> of <strong><code>ss</code></strong> in the terminal for a detailed overview of how to use the command:</p>
<pre class="wp-block-code"><code>man ss</code></pre>
<p>For a quick overview of the available options, enter:</p>
<pre class="wp-block-code"><code>ss -h</code></pre>
<h2 class="ftwp-heading" id="ftoc-heading-14">netstat VS ss Command</h2>
<p>The <strong><code>ss</code></strong> command is considered a replacement command for the obsolete <strong><code>netstat</code></strong>. The speed and better filtering options of CLI utilities from the iproute2 software package are preferable to the net-tools software package.</p>
<p>The netstat man page lists <strong><code>ss</code></strong> as the superior alternative. The netstat tool is still available to use. However, ss is a better and faster option.</p>
<p class="h3">Conclusion</p>
<p>The ss tool allows the investigation of socket and network statistics with advanced filtering options for a better troubleshooting experience. This utility is a must-know tool for any system and network administrator.</p>
<p>Check out our list of the <a href="https://phoenixnap.com/blog/best-network-security-tools" target="_blank" rel="noreferrer noopener">best network security tools</a> to minimize threats to your network environment.</p>
<div class="entry-readmore"><div class="entry-readmore-btn"></div></div>                                                        <div class="entry-copyright"><p>原创文章，作者：奋斗，如若转载，请注明出处：https://blog.ytso.com/tech/aiops/224303.html</p></div>                        </div>

                        <div class="entry-tag"></div>
                        <div class="entry-action">
                            <div class="btn-zan" data-id="224303"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-thumb-up-fill"></use></svg></i> 赞 <span class="entry-action-num">(0)</span></div>
                                                    </div>

                        <div class="entry-bar">
                            <div class="entry-bar-inner">
                                                                <div class="entry-bar-info entry-bar-info2">
                                    <div class="info-item meta">
                                                                                    <a class="meta-item j-heart" href="javascript:;" data-id="224303"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-star"></use></svg></i> <span class="data">0</span></a>                                        <a class="meta-item" href="#comments"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-comment"></use></svg></i> <span class="data">0</span></a>                                                                            </div>
                                    <div class="info-item share">
                                                                                    <a class="meta-item mobile j-mobile-share" href="javascript:;" data-id="224303" data-qrcode="https://blog.ytso.com/tech/aiops/224303.html">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-share"></use></svg></i> 生成海报                                            </a>
                                                                                    <a class="meta-item wechat" data-share="wechat" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-wechat"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item weibo" data-share="weibo" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-weibo"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item qq" data-share="qq" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-qq"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item qzone" data-share="qzone" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-qzone"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item douban" data-share="douban" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-douban"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item linkedin" data-share="linkedin" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-linkedin"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item facebook" data-share="facebook" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-facebook"></use></svg></i>                                            </a>
                                                                                    <a class="meta-item twitter" data-share="twitter" target="_blank" rel="nofollow noopener noreferrer" href="#">
                                                <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-twitter"></use></svg></i>                                            </a>
                                                                            </div>
                                    <div class="info-item act">
                                        <a href="javascript:;" id="j-reading"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-article"></use></svg></i></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                                            <div class="entry-page">
                    <div class="entry-page-prev j-lazy" style="background-image: url('https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png');" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107105738616.png">
                <a href="https://blog.ytso.com/tech/aiops/224302.html" title="How to Use the Linux tee Command" rel="prev">
                    <span>How to Use the Linux tee Command</span>
                </a>
                <div class="entry-page-info">
                    <span class="pull-left"><i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-arrow-left-double"></use></svg></i> 上一篇</span>
                    <span class="pull-right">2022年1月7日 11:10</span>
                </div>
            </div>
                            <div class="entry-page-next j-lazy" style="background-image: url('https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png');" data-original="http://ytso-blog-oss-img.oss-accelerate.aliyuncs.com/wp-content/uploads/2022/01/07/20220107111307488.png">
                <a href="https://blog.ytso.com/tech/aiops/224304.html" title="How to Fix SSH Failed Permission Denied (publickey,gssapi-keyex,gssapi-with-mic)" rel="next">
                    <span>How to Fix SSH Failed Permission Denied (publickey,gssapi-keyex,gssapi-with-mic)</span>
                </a>
                <div class="entry-page-info">
                    <span class="pull-right">下一篇 <i class="wpcom-icon wi"><svg aria-hidden="true"><use xlink:href="#wi-arrow-right-double"></use></svg></i></span>
                    <span class="pull-left">2022年1月7日 11:11</span>
                </div>
            </div>
            </div>
                                        <error>
    <code>wp_die</code>
    <title><![CDATA[WordPress &amp;rsaquo; Error]]></title>
    <message><![CDATA[&lt;h1&gt;Error establishing a Redis connection&lt;/h1&gt;
&lt;p&gt;To disable Redis, delete the &lt;code&gt;object-cache.php&lt;/code&gt; file in the &lt;code&gt;/wp-content/&lt;/code&gt; directory.&lt;/p&gt;
]]></message>
    <data>
        <status>500</status>
    </data>
</error>
<!--
Performance optimized by Redis Object Cache. Learn more: https://wprediscache.com

Retrieved 1840 objects (472 KB) from Redis using Predis (v2.4.0).
-->
