Sorry for being late guys but thanks heaps for those replies. I cant believe i also forgot lsof or fuser. i didnt know the netstat -p switch. Thank you so much guys you guys are awesome.
On Mon, Mar 17, 2008 at 7:38 PM, Peter Hardy <[EMAIL PROTECTED]> wrote: > On Mon, 2008-03-17 at 17:58 +0900, Hasnain wrote: > > Is there anyway how to find which process is holding a tcp port in > linux? > > Say for instance, i checked > > > > netstat -a |grep ###. but i dont know which process has opened or hold > that > > port currently. Is there anyway to find out this? > > Nobody has yet mentioned lsof or fuser. This makes me sad. > > [EMAIL PROTECTED]:~% ps ax | grep light > 14230 ? SN 0:01 /usr/sbin/lighttpd -f > /etc/lighttpd/lighttpd.conf > [EMAIL PROTECTED]:~% sudo fuser -n tcp 80 > 80/tcp: 14230 > [EMAIL PROTECTED]:~% sudo lsof -i :80 > COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME > lighttpd 14230 www-data 5u IPv4 64209 TCP *:www (LISTEN) > [EMAIL PROTECTED]:~% > > Hooray for everything being a file! > > -- > Pete > > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
