Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
villivateur committed May 7, 2024
1 parent f15c9d4 commit 5cba37e
Show file tree
Hide file tree
Showing 156 changed files with 20,235 additions and 614 deletions.
278 changes: 278 additions & 0 deletions 2024/05/07/Linux-show-all-listening-ports/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:description" content="嵌入式物联网全栈系统工程师">
<meta property="og:type" content="website">
<meta name="description" content="嵌入式物联网全栈系统工程师">
<meta name="keywords" content="冯锦瑾, villivateur, 嵌入式工程猫">
<link rel="shortcut icon" href="/favicon.ico">

<title>

在 Linux 中显示所有正在监听的 TCP 端口 - 嵌入式工程猫的博客

</title>

<!-- Custom CSS -->

<link rel="stylesheet" href="/css/aircloud.css">

<!--
<link rel="stylesheet" href="/css/gitment.css">
-->
<!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
<link href="/static/font_620856_pl6z7sid89qkt9.css" rel="stylesheet" type="text/css">
<!-- ga & ba script hoook -->
<script></script>
<meta name="generator" content="Hexo 6.3.0"></head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>

<div class="index-about">
<i> 嵌入式工程猫的博客 </i>
</div>

<div class="index-container">

<div class="index-left">

<div class="nav" id="nav">
<div class="avatar-name">
<div class="avatar ">
<img src="/static/me.png" />
</div>
<div class="name">
<i>嵌入式工程猫</i>
</div>
</div>
<div class="contents" id="nav-content">
<ul>
<li >
<a href="/">
<i class="iconfont icon-shouye1"></i>
<span>主页</span>
</a>
</li>
<li >
<a href="/tags">
<i class="iconfont icon-biaoqian1"></i>
<span>标签</span>
</a>
</li>
<li >
<a href="/archives">
<i class="iconfont icon-guidang2"></i>
<span>存档</span>
</a>
</li>
<li>
<a href="/sponsor/">
<i class="iconfont icon-guidang"></i>
<span><b>请赞助我</b></span>
</a>
</li>

</ul>
</div>

<div id="toc" class="toc-article">
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#netstat"><span class="toc-text">netstat</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#lsof"><span class="toc-text">lsof</span></a></li></ol>
</div>

</div>


<div class="search-field" id="search-field">
<div class="search-bg" id="search-bg"></div>
<div class="search-container">
<div class="search-input">
<span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
<input id="search-input"/>
<span id="begin-search">搜索</span>
</div>
<div class="search-result-container" id="search-result-container">

</div>
</div>
</div>

<div class="index-about-mobile">
<i> 嵌入式工程猫的博客 </i>
</div>
</div>

<div class="index-middle">
<!-- Main Content -->



<div class="post-container">
<div class="post-title">
在 Linux 中显示所有正在监听的 TCP 端口
</div>

<div class="post-meta">
<span class="attr">发布于:<span>2024-05-07 20:35:26</span></span>

<span class="attr">标签:/

<a class="tag" href="/tags/#Linux" title="Linux">Linux</a>
<span>/</span>

<a class="tag" href="/tags/#网络通信" title="网络通信">网络通信</a>
<span>/</span>


</span>
</div>
<div class="post-content no-indent">
<h2 id="netstat"><a href="#netstat" class="headerlink" title="netstat"></a>netstat</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo netstat -tulpn | grep LISTEN</span><br></pre></td></tr></table></figure>

<p>其中 <code>-t</code> 表示显示 TCP,<code>-u</code> 表示显示 UDP,<code>-l</code> 表示显示监听的端口,<code>-p</code> 表示显示对应的程序名,<code>-n</code> 表示不去查询 IP 对应的主机名。</p>
<h2 id="lsof"><a href="#lsof" class="headerlink" title="lsof"></a>lsof</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo lsof -i -P -n | grep LISTEN</span><br></pre></td></tr></table></figure>

<p>其中 <code>-i</code> 表示显示 IP 协议,<code>-P</code> 表示把端口号保留为数字形式,<code>-n</code> 表示不去查询 IP 对应的主机名。</p>


<br />
<div id="comment-container">
</div>
<div id="disqus_thread"></div>
<div id="lv-container"></div>
<div class="giscus"></div>
</div>
</div>


<div style="text-align: center;">
<button style="font-size: large; width: 80%;" id="loadDisqusButton" onclick="loadDisqus()">
点击加载评论组件
<br>
请确保您的网络环境可以访问 Disqus
</button>
</div>

</div>
</div>


<footer class="footer">
<ul class="list-inline text-center">


<li>
<a target="_blank" href="https://www.zhihu.com/people/vvzero">
<span class="fa-stack fa-lg">
<i class="iconfont icon-zhihu"></i>
</span>
</a>
</li>







<li>
<a target="_blank" href="https://github.com/villivateur">
<span class="fa-stack fa-lg">
<i class="iconfont icon-github"></i>
</span>
</a>
</li>



<li>
<a target="_blank" href="https://www.linkedin.com/in/villivateur">
<span class="fa-stack fa-lg">
<i class="iconfont icon-linkedin"></i>
</span>
</a>
</li>


</ul>

<p>
<span>/</span>

<span><a target="_blank" rel="noopener" href="https://www.suruifu.com/">苏瑞辅的个人网站</a></span>
<span>/</span>

<span><a target="_blank" rel="noopener" href="https://blog.triplez.cn/">TripleZ&#39;s Blog</a></span>
<span>/</span>

<span><a target="_blank" rel="noopener" href="https://blog.qrzbing.cn/">迷茫中前行</a></span>
<span>/</span>

<span><a target="_blank" rel="noopener" href="https://milkice.me/">Milkice&#39;s IceBox 奶冰の冷藏室</a></span>
<span>/</span>

<span><a target="_blank" rel="noopener" href="https://muyun.work/">Muyun的杂谈</a></span>
<span>/</span>

</p>

<p>
<a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a> 创建 | 主题 <a target="_blank" rel="noopener" href="https://github.com/aircloud/hexo-theme-aircloud">AirCloud</a> | <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/">苏ICP备17037222号</a></p>
</footer>




</body>

<script>
// We expose some of the variables needed by the front end
window.hexo_search_path = "search.xml"
window.hexo_root = "/"
window.isPost = true
</script>
<script src="/static/jquery-3.3.1.min.js"></script>

<script src="/js/index.js"></script>



<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
function loadDisqus() {
var elem = document.getElementById("loadDisqusButton");
elem.remove();

if( '' || '')
var disqus_config = function () {
this.page.url = ''; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = ''; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://villivateur.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
}
</script>





</html>
Loading

0 comments on commit 5cba37e

Please sign in to comment.