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