I have an ssh server running in daemon mode, I believe, so /etc/init.d/sshd stop wont work. I've tried finding this listening port with netstat (netstat -atx |grep 22) but there are too many processes to list.
How do I find a pid using netstat?
asked 11 May '10, 16:33
This should do the trick for you:
You'll get something like this:
The '17322' is the PID in this case.
answered 11 May '10, 16:48
Is there a reason you can't use ps?
would give you the PID easily.
answered 11 May '10, 23:50
As root, run:
you should receive something that looks like this:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:37 0.0.0.0:* LISTEN 3425/inetd
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 3640/X
tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN 3425/inetd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7586/sshd
0.0.0.0:* indicates port 22 is listening on all addresses.
To search only for sshd, pipe netstat with grep: