old blog,

Finding What Process is Binding Network Socket / Port

Izhar Firdaus Izhar Firdaus Follow Support Jul 21, 2006 · 1 min read
Finding What Process is Binding Network Socket / Port
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.
I found a very usefull site for this purpose. It guide you step by step on how to find the process.

http://linux-sxs.org/networking/portnumid.html

From the site, I wrote a script to ease the process.

#!/bin/bash
#
# Script to find what process is binding to which network socket
# Usage
# portowner <port>
# portowner all
#
# Author
# Mohd Izhar Firdaus Ismail <kagesenshi.87@gmail.com>
#

findproc(){
PIDS=`fuser -n tcp $@ 2>/dev/null`
echo "--------------"
echo "Port $@"
ps $PIDS
echo "-------------"
}

if [ "$1" == "" ];then
echo "Usage:"
echo " $( basename $0 <port> ) "
echo " $( basename $0 ) all"
elif [ "$1" == "all" ];then
PORTS=`netstat -na|grep tcp\
|grep LISTEN|sed s/"\:\:\:"/"0.0.0.0\:"/g \
|sed s/"\:"/" "/g|awk '{print $5}'|sort|uniq`
for PORT in $PORTS;do
findproc $PORT ;
done
else
for PORT in $@;do
findproc $PORT ;
done
fi
Written by Izhar Firdaus Follow Support
I'm a system architect, data engineer and developer advocate with passion in Free / Open Source software, entrepreneurship, community building, education and martial art. I take enjoyment in bridging and bringing together different FOSS technologies to help businesses and organizations utilize IT infrastructure to aid and optimize their business and organizational process.

Popping gnome-run from script

I wanted to create a .desktop file to pop gnome-run and put it at the gnome-menu ( the new gnome-menu doesnt have it ) - simply becau...

In old blog, Jul 21, 2006

« Previous Post

Connect Googletalk to other IM's using Jabber Transports

I found this nice article while playing around with Gajim to connect to my googletalk account using port 443http://blog.outer-court.c...

In old blog, Jul 21, 2006

Next Post »