简体   繁体   中英

Find pid of a process while its rinning on background

I have python sunning on my PC in a Linux machine .

ps -eaf | grep python

But now i dont know the process name say . Python is running on the port 7777. I only know the port no on which python with the bellow command .

netstat 

Now i want to find out the pid no of python which is running on port 7777. as i dont know the process name i only know port no 7777 . are there any command for the same problem .

You have to use following :

lsof -i :7777

I will show you pid without knowing the process name , but knowing the port no

sudo netstat -tunlp | grep :7777

You can use either netstat (deprecated) or ss , with the same options which are mnemonic:

-t = TCP
-u = UDP
-n = numeric output
-l = listening ports
-p = pid

Another commands that works, apart, from lsof , is fuser (the Linux one because the BSD's is different).

sudo fuser -n tcp -n 7777

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM