语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -3,9 +3,9 @@
<h2 id="补充说明">补充说明</h2>
<p><strong>netstat命令</strong> 用来打印Linux中网络系统的状态信息可让你得知整个Linux系统的网络情况。</p>
<h3 id="语法">语法</h3>
<pre><code>netstat(选项)</code></pre>
<pre><code class="language-bash">netstat(选项)</code></pre>
<h3 id="选项">选项</h3>
<pre><code>-a或--all显示所有连线中的Socket
<pre><code class="language-bash">-a或--all显示所有连线中的Socket
-A&lt;网络类型&gt;或--&lt;网络类型&gt;:列出该网络类型连线中的相关地址;
-c或--continuous持续列出网络状态
-C或--cache显示路由器配置的快取信息
@@ -31,56 +31,56 @@
--ip或--inet此参数的效果和指定&quot;-A inet&quot;参数相同。</code></pre>
<h3 id="实例">实例</h3>
<p><strong>列出所有端口 (包括监听和未监听的)</strong></p>
<pre><code>netstat -a #列出所有端口
<pre><code class="language-bash">netstat -a #列出所有端口
netstat -at #列出所有tcp端口
netstat -au #列出所有udp端口 </code></pre>
<p><strong>列出所有处于监听状态的 Sockets</strong></p>
<pre><code>netstat -l #只显示监听端口
<pre><code class="language-bash">netstat -l #只显示监听端口
netstat -lt #只列出所有监听 tcp 端口
netstat -lu #只列出所有监听 udp 端口
netstat -lx #只列出所有监听 UNIX 端口</code></pre>
<p><strong>显示每个协议的统计信息</strong></p>
<pre><code>netstat -s 显示所有端口的统计信息
<pre><code class="language-bash">netstat -s 显示所有端口的统计信息
netstat -st 显示TCP端口的统计信息
netstat -su 显示UDP端口的统计信息
</code></pre>
<p><strong>在netstat输出中显示 PID 和进程名称</strong></p>
<pre><code>netstat -pt</code></pre>
<pre><code class="language-bash">netstat -pt</code></pre>
<p><code>netstat -p</code>可以与其它开关一起使用就可以添加“PID/进程名称”到netstat输出中这样debugging的时候可以很方便的发现特定端口运行的程序。</p>
<p><strong>在netstat输出中不显示主机端口和用户名(host, port or user)</strong></p>
<p>当你不想让主机,端口和用户名显示,使用<code>netstat -n</code>。将会使用数字代替那些名称。同样可以加速输出,因为不用进行比对查询。</p>
<pre><code>netstat -an</code></pre>
<pre><code class="language-bash">netstat -an</code></pre>
<p>如果只是不想让这三个名称中的一个被显示,使用以下命令:</p>
<pre><code>netsat -a --numeric-ports
<pre><code class="language-bash">netsat -a --numeric-ports
netsat -a --numeric-hosts
netsat -a --numeric-users</code></pre>
<p><strong>持续输出netstat信息</strong></p>
<pre><code>netstat -c #每隔一秒输出网络信息</code></pre>
<pre><code class="language-bash">netstat -c #每隔一秒输出网络信息</code></pre>
<p><strong>显示系统不支持的地址族(Address Families)</strong></p>
<pre><code>netstat --verbose</code></pre>
<pre><code class="language-bash">netstat --verbose</code></pre>
<p>在输出的末尾,会有如下的信息:</p>
<pre><code>netstat: no support for `AF IPX&#39; on this system.
<pre><code class="language-bash">netstat: no support for `AF IPX&#39; on this system.
netstat: no support for `AF AX25&#39; on this system.
netstat: no support for `AF X25&#39; on this system.
netstat: no support for `AF NETROM&#39; on this system.</code></pre>
<p><strong>显示核心路由信息</strong></p>
<pre><code>netstat -r</code></pre>
<pre><code class="language-bash">netstat -r</code></pre>
<p>使用<code>netstat -rn</code>显示数字格式,不查询主机名称。</p>
<p><strong>找出程序运行的端口</strong></p>
<p>并不是所有的进程都能找到,没有权限的会不显示,使用 root 权限查看所有的信息。</p>
<pre><code>netstat -ap | grep ssh</code></pre>
<pre><code class="language-bash">netstat -ap | grep ssh</code></pre>
<p>找出运行在指定端口的进程:</p>
<pre><code>netstat -an | grep &#39;:80&#39;</code></pre>
<pre><code class="language-bash">netstat -an | grep &#39;:80&#39;</code></pre>
<p><strong>通过端口找进程ID</strong></p>
<div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb15-1" data-line-number="1"><span class="fu">netstat</span> -anp<span class="kw">|</span><span class="fu">grep</span> 8081 <span class="kw">|</span> <span class="fu">grep</span> LISTEN<span class="kw">|</span><span class="fu">awk</span> <span class="st">&#39;{printf $7}&#39;</span><span class="kw">|</span><span class="fu">cut</span> -d/ -f1</a></code></pre></div>
<div class="sourceCode" id="cb15"><pre><code class="language-bash"><a class="sourceLine" id="cb15-1" data-line-number="1"><span class="fu">netstat</span> -anp<span class="kw">|</span><span class="fu">grep</span> 8081 <span class="kw">|</span> <span class="fu">grep</span> LISTEN<span class="kw">|</span><span class="fu">awk</span> <span class="st">&#39;{printf $7}&#39;</span><span class="kw">|</span><span class="fu">cut</span> -d/ -f1</a></code></pre></div>
<p><strong>显示网络接口列表</strong></p>
<pre><code>netstat -i</code></pre>
<pre><code class="language-bash">netstat -i</code></pre>
<p>显示详细信息像是ifconfig使用<code>netstat -ie</code></p>
<p><strong>IP和TCP分析</strong></p>
<p>查看连接某服务端口最多的的IP地址</p>
<pre><code>netstat -ntu | grep :80 | awk &#39;{print $5}&#39; | cut -d: -f1 | awk &#39;{++ip[$1]} END {for(i in ip) print ip[i],&quot;\t&quot;,i}&#39; | sort -nr</code></pre>
<pre><code class="language-bash">netstat -ntu | grep :80 | awk &#39;{print $5}&#39; | cut -d: -f1 | awk &#39;{++ip[$1]} END {for(i in ip) print ip[i],&quot;\t&quot;,i}&#39; | sort -nr</code></pre>
<p>TCP各种状态列表</p>
<pre><code>netstat -nt | grep -e 127.0.0.1 -e 0.0.0.0 -e ::: -v | awk &#39;/^tcp/ {++state[$NF]} END {for(i in state) print i,&quot;\t&quot;,state[i]}&#39;</code></pre>
<pre><code class="language-bash">netstat -nt | grep -e 127.0.0.1 -e 0.0.0.0 -e ::: -v | awk &#39;/^tcp/ {++state[$NF]} END {for(i in state) print i,&quot;\t&quot;,state[i]}&#39;</code></pre>
<p>查看phpcgi进程数如果接近预设值说明不够用需要增加</p>
<pre><code>netstat -anpo | grep &quot;php-cgi&quot; | wc -l</code></pre>
<pre><code class="language-bash">netstat -anpo | grep &quot;php-cgi&quot; | wc -l</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->