{"id":63732,"date":"2025-04-29T15:31:47","date_gmt":"2025-04-29T07:31:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63732\/"},"modified":"2025-04-29T15:31:47","modified_gmt":"2025-04-29T07:31:47","slug":"linux%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b%e7%ab%af%e5%8f%a3%e5%8f%b7-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63732\/","title":{"rendered":"linux\u600e\u4e48\u67e5\u770b\u7aef\u53e3\u53f7"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u67e5\u770b linux \u7cfb\u7edf\u4e2d\u7684\u7aef\u53e3\u53f7\uff1a\u4f7f\u7528 netstat \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4fa6\u542c\u6216\u5df2\u5efa\u7acb\u8fde\u63a5\u7684\u7aef\u53e3\u53f7\u3002\u4f7f\u7528 lsof \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002\u4f7f\u7528 ss \u547d\u4ee4\u67e5\u770b\u4e0e netstat \u7c7b\u4f3c\u4f46\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u4f7f\u7528 grep \u547d\u4ee4\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u641c\u7d22\u7279\u5b9a\u7aef\u53e3\u53f7\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/04\/2024060414391750670.jpg\" class=\"aligncenter\" title=\"linux\u600e\u4e48\u67e5\u770b\u7aef\u53e3\u53f7\u63d2\u56fe\" alt=\"linux\u600e\u4e48\u67e5\u770b\u7aef\u53e3\u53f7\u63d2\u56fe\" \/><\/p>\n<p><strong>Linux\u4e0b\u67e5\u770b\u7aef\u53e3\u53f7<\/strong><\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u7aef\u53e3\u53f7\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 netstat \u547d\u4ee4<\/strong><\/p>\n<p>netstat \u547d\u4ee4\u662f\u7528\u6765\u67e5\u770b\u7f51\u7edc\u8fde\u63a5\u548c\u7aef\u53e3\u7684\u4fe1\u606f\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>netstat -tulpn<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u6709\u6b63\u5728\u4fa6\u542c\u6216\u5df2\u5efa\u7acb\u8fde\u63a5\u7684\u7aef\u53e3\u3002\u8f93\u51fa\u4e2d\u7684 &#8220;Local Address&#8221; \u5217\u663e\u793a\u4e86\u672c\u673a\u4e0a\u7684\u7aef\u53e3\u53f7\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 lsof \u547d\u4ee4<\/strong><\/p>\n<p>lsof \u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u6253\u5f00\u7684\u6587\u4ef6\uff0c\u5305\u62ec\u7f51\u7edc\u5957\u63a5\u5b57\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>lsof -i<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u6709\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u3002\u8f93\u51fa\u4e2d\u7684 &#8220;NAME\/PID&#8221; \u5217\u663e\u793a\u4e86\u6b63\u5728\u4f7f\u7528\u7aef\u53e3\u7684\u8fdb\u7a0b\u7684\u540d\u79f0\u548cPID\u3002<\/p>\n<p><strong>3. \u4f7f\u7528 ss \u547d\u4ee4<\/strong><\/p>\n<p>ss \u547d\u4ee4\u4e0e netstat \u7c7b\u4f3c\uff0c\u4f46\u63d0\u4f9b\u4e86\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ss -tulpn<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u4e0e netstat -tulpn \u547d\u4ee4\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002<\/p>\n<p><strong>4. \u4f7f\u7528 grep \u547d\u4ee4<\/strong><\/p>\n<p>grep \u547d\u4ee4\u53ef\u4ee5\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u641c\u7d22\u7279\u5b9a\u6a21\u5f0f\u3002\u8981\u641c\u7d22\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>grep \":port_number\" \/proc\/net\/tcp<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u641c\u7d22\u5305\u542b\u6307\u5b9a\u7aef\u53e3\u53f7\u7684 \/proc\/net\/tcp \u6587\u4ef6\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u67e5\u770b\u7aef\u53e3\u53f7\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u67e5\u770b linux \u7cfb\u7edf\u4e2d\u7684\u7aef\u53e3\u53f7\uff1a\u4f7f\u7528 netstat \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4fa6\u542c\u6216\u5df2\u5efa\u7acb\u8fde\u63a5\u7684\u7aef\u53e3\u53f7\u3002\u4f7f\u7528 lsof \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002\u4f7f\u7528 ss \u547d\u4ee4\u67e5\u770b\u4e0e netstat \u7c7b\u4f3c\u4f46\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u4f7f\u7528 grep \u547d\u4ee4\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u641c\u7d22\u7279\u5b9a\u7aef\u53e3\u53f7\u3002 Linux\u4e0b\u67e5\u770b\u7aef\u53e3\u53f7 \u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u7aef\u53e3\u53f7\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a 1. \u4f7f\u7528 netstat \u547d\u4ee4 netstat \u547d\u4ee4\u662f\u7528\u6765\u67e5\u770b\u7f51\u7edc\u8fde\u63a5\u548c\u7aef\u53e3\u7684\u4fe1\u606f\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a netstat -tulpn \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u6709\u6b63\u5728\u4fa6\u542c\u6216\u5df2\u5efa\u7acb\u8fde\u63a5\u7684\u7aef\u53e3\u3002\u8f93\u51fa\u4e2d\u7684 &#8220;Local Address&#8221; \u5217\u663e\u793a\u4e86\u672c\u673a\u4e0a\u7684\u7aef\u53e3\u53f7\u3002 2. \u4f7f\u7528 lsof \u547d\u4ee4 lsof \u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u6253\u5f00\u7684\u6587\u4ef6\uff0c\u5305\u62ec\u7f51\u7edc\u5957\u63a5\u5b57\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a lsof -i \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u6709\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u3002\u8f93\u51fa\u4e2d\u7684 &#8220;NAME\/PID&#8221; \u5217\u663e\u793a\u4e86\u6b63\u5728\u4f7f\u7528\u7aef\u53e3\u7684\u8fdb\u7a0b\u7684\u540d\u79f0\u548cPID\u3002 3. \u4f7f\u7528 ss \u547d\u4ee4 ss \u547d\u4ee4\u4e0e netstat \u7c7b\u4f3c\uff0c\u4f46\u63d0\u4f9b\u4e86\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u8981\u67e5\u770b\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a ss -tulpn \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u4e0e netstat -tulpn \u547d\u4ee4\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63732","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63732"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63732\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}