sudo lsof -i:22 - List all open internet sockets using port 22 (who is using port 22)
sudo lsof -i4 -sTCP:LISTEN - List all IPv4 internet sockets (-i4) in state Listen (-sTCP:LISTEN) This is should list all listening services (not working on centos 5)
sudo lsof -i4 -sTCP:LISTEN -P - As above but don't lookup service names
sudo lsof -u icecast - List all open files used by user icecast (-u icecast)
sudo lsof -u icecast -a -i List all open files used by user icecast and (-a) only internet sockets (-i)
sudo lsof -p 3893 - List all open files of pid 3893
sudo lsof -P -c ushare -a -i - List open files for processes executing a command beginning with "ushare" (-c) and (-a) internet sockets. Don't lookup the service in /etc/services(-P)
sudo lsof -P -c ushare -a -i -sTCP:LISTEN As above but only the the listening ports for TCP
sudo lsof -i4 -sTCP:LISTEN -a -p 3792 -P - Show listening IP4 TCP ports for process 3792
sudo lsof -P -c ushare -a -i - List open files for processes executing a command beginning with "ushare" (-c) and (-a) internet sockets. Don't lookup the service in /etc/services(-P)
sudo lsof -P -c ushare -a -i -sTCP:LISTEN As above but only the the listening ports for TCP
sudo lsof -i4 -sTCP:LISTEN -a -p 3792 -P - Show listening IP4 TCP ports for process 3792