Linux: Find Out Which Process Is Listening Upon a Port

netstat -tulpn | grep :80
-p, --program
Show the PID and name of the program to which each socket belongs.
-l, --listening
Show only listening sockets.  (These are omitted by default.)
--numeric , -n
Show  numerical addresses instead of trying to determine symbolic host, port or user names.

fuser 7000/tcp

Find Out Current Working Directory Of a Process
ls -l /proc/3813/cwd
pwdx 3813

cat /proc/3813/environ

Find Out Owner Of a Process
ps aux | grep 3813

lsof Command Example
lsof -i :portNumber
lsof -i tcp:portNumber
lsof -i udp:portNumber
lsof -i :80
lsof -i :80 | grep LISTEN

I Discover an Open Port Which I Don't Recognize At All
The file /etc/services is used to map port numbers and protocols to service names
grep port /etc/services
http://www.cyberciti.biz/faq/what-process-has-open-linux-port/

No comments:

Post a Comment