Files
StudyDiary-20261009/10-WebClipper/Linux查看某个程序占用的端口号_linux查询某个程序的端口号-CSDN博客.md
CrazyJasonwell e97be9ac8c commit all
2026-10-09 22:06:40 +08:00

51 lines
1.2 KiB
Markdown
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
created: 2025-08-31T08:19
updated: 2025-08-31T08:19
---
最新推荐文章于 2025-06-22 13:56:30 发布
原创 于 2019-08-21 13:48:45 发布 · 2.7w 阅读
· ![](https://csdnimg.cn/release/blogv2/dist/pc/img/newHeart2023Black.png)
12
· ![](https://csdnimg.cn/release/blogv2/dist/pc/img/tobarCollect2.png)
38 ·
CC 4.0 BY-SA版权
版权声明:本文为博主原创文章,遵循 [CC 4.0 BY-SA](http://creativecommons.org/licenses/by-sa/4.0/) 版权协议,转载请附上原文出处链接和本声明。
#### 1\. 首先查看程序的进程号
例如程序名称为aaa,查询其运行进程号如下:
```
`minbo@mb ~> ps -aux | grep aaa
minbo 16273 0.3 1.1 21475099312 92752 pts/2 Sl+ 10:18 0:01 ./aaa`
* 1
* 2
```
则进程号就是`16273`。
#### 2\. 查看进程所占端口号
上面我们查到程序的进程号是`16273`,查询其占用端口号如下:
```
`minbo@mb ~> sudo netstat -ap | grep "16273" // windows用findstr代替grep
[sudo] minbo 的密码:
tcp 0 0 mb:60272 10.80.23.122:26575 ESTABLISHED 16273/./aaa`
* 1
* 2
* 3
```
可以看到该运行程序有一个`TCP`连接,客户端端口是`60272`,服务端ip是`10.80.23.122`,端口是`26575`。