231 lines
6.9 KiB
HTML
231 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
|
|
<meta http-equiv="X-Content-Type-Options" content="nosniff">
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="icon" type="image/x-icon" href="../favicon.ico">
|
|
<script>
|
|
// Apply theme immediately to prevent flash
|
|
(function() {
|
|
const theme = localStorage.getItem('theme') ||
|
|
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
})();
|
|
</script>
|
|
<title>ss Cheatsheet - Cheatsheets - Launch Pad</title>
|
|
</head>
|
|
<body>
|
|
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
|
|
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
|
|
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
|
|
</button>
|
|
<br/><br/>
|
|
<div class="name">
|
|
__ _______________________ _________._________________________
|
|
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
|
|
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
|
|
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
|
|
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
|
|
\/ \/ \/ \/ \/ \/ \/
|
|
</div>
|
|
<div class="blog-page-header">
|
|
<div class="blog-header-content">
|
|
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
|
|
</a>
|
|
<h1 class="blog-page-title">ss Cheatsheet</h1>
|
|
</div>
|
|
</div>
|
|
<div class="blog-post-container">
|
|
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
|
|
<div class="blog-post">
|
|
<div class="blog-post-content">
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
<hr>
|
|
<p>ss (socket statistics) is a modern replacement for netstat. Displays network socket information including TCP, UDP, and Unix domain sockets. Faster and more feature-rich than netstat.</p>
|
|
<hr>
|
|
<h2>Basic Usage</h2>
|
|
<ul>
|
|
<li>ss - All sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -t - TCP sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -u - UDP sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -l - Listening sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -a - All sockets (listening + established)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -n - Numeric addresses</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Socket Types</h2>
|
|
<ul>
|
|
<li>-t - TCP sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-u - UDP sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-w - Raw sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-x - Unix domain sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-S - SCTP sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-D - DCCP sockets</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>State Filters</h2>
|
|
<ul>
|
|
<li>-l - Listening sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-a - All sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-s - Summary statistics</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-e - Extended information</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-o - Timer information</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-m - Memory information</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Address Filters</h2>
|
|
<ul>
|
|
<li>ss -n - No hostname resolution</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -p - Show process information</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -i - Internal TCP information</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -K - Force close socket</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -H - Suppress header</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Port & Address Filters</h2>
|
|
<ul>
|
|
<li>ss -tlnp - TCP listening with process</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -tlnp :80 - Port 80</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -tlnp 'sport = :80' - Source port 80</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -tlnp 'dport = :80' - Destination port 80</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -tlnp 'src 192.168.1.1' - Source address</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ss -tlnp 'dst 192.168.1.1' - Destination address</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Common Examples</h2>
|
|
<h3>All Listening</h3>
|
|
<pre><code>ss -tlnp</code></pre>
|
|
<p>TCP listening sockets with process.</p>
|
|
<h3>All Connections</h3>
|
|
<pre><code>ss -tunp</code></pre>
|
|
<p>TCP and UDP with process.</p>
|
|
<h3>Specific Port</h3>
|
|
<pre><code>ss -tlnp :80</code></pre>
|
|
<p>What's listening on port 80.</p>
|
|
<h3>Port Range</h3>
|
|
<pre><code>ss -tlnp 'sport > :1024 and sport < :65535'</code></pre>
|
|
<p>Ports in range.</p>
|
|
<h3>Established Connections</h3>
|
|
<pre><code>ss -tn state established</code></pre>
|
|
<p>Active TCP connections.</p>
|
|
<h3>Summary</h3>
|
|
<pre><code>ss -s</code></pre>
|
|
<p>Socket statistics summary.</p>
|
|
<h3>Process Info</h3>
|
|
<pre><code>ss -tlnp</code></pre>
|
|
<p>Show process using sockets.</p>
|
|
<h3>Memory Usage</h3>
|
|
<pre><code>ss -m</code></pre>
|
|
<p>Socket memory information.</p>
|
|
<h3>Extended Info</h3>
|
|
<pre><code>ss -e</code></pre>
|
|
<p>Extended socket information.</p>
|
|
<h3>Unix Sockets</h3>
|
|
<pre><code>ss -xlnp</code></pre>
|
|
<p>Unix domain sockets.</p>
|
|
<hr>
|
|
<h2>State Filters</h2>
|
|
<ul>
|
|
<li>state established - Established connections</li>
|
|
</ul>
|
|
<ul>
|
|
<li>state listening - Listening sockets</li>
|
|
</ul>
|
|
<ul>
|
|
<li>state time-wait - Time-wait state</li>
|
|
</ul>
|
|
<ul>
|
|
<li>state fin-wait-1 - Fin-wait-1 state</li>
|
|
</ul>
|
|
<ul>
|
|
<li>state fin-wait-2 - Fin-wait-2 state</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Tips</h2>
|
|
<ul>
|
|
<li>Use -tlnp for common network troubleshooting</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -p to see which process owns socket</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -n for faster output (no DNS lookup)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -s for quick statistics</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Faster than netstat</li>
|
|
</ul>
|
|
<ul>
|
|
<li>More detailed than netstat</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Essential for network debugging</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use filters to narrow results</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script async type="text/javascript" src="../blog/analytics.js"></script>
|
|
<script src="../theme.js"></script>
|
|
</body>
|
|
</html>
|
|
|