Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道哪个应用程序正在侦听 linux 机器上的端口。
有多个服务器,apache 以及不在一台机器上的东西,我想知道哪个服务器正在侦听哪个端口,而不必深入研究每个服务器的配置文件。
是否有一个命令列出可执行文件的路径以及它正在侦听的端口?
netstat -t -l -p将列出侦听端口以及创建套接字的 pid 和进程名称。由于您拥有 pid,因此您可以使用它ps PID来查找可执行文件的路径。
netstat -t -l -p
ps PID
还lsof -i:<port number>应该给你进程的PID,你可以用它ps <pid>来查找路径
lsof -i:<port number>
ps <pid>