HOW TO : Find out which network port a program is using in linux

Quick way to figure out, which ports a particular program is using in linux

[bash] netstat -plan | grep -i PROGRAM_NAME [/bash]

Example : Check which ports SSH is listening on

[bash]

samurai@samurai:~$ sudo /bin/netstat -plan | grep sshd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      5257/sshd
tcp        0     52 123.123.123.123:22      124.124.124.124:32846     ESTABLISHED 3551/sshd: samurai
tcp6       0      0 :::22                   :::*                    LISTEN      5257/sshd
unix  3      [ ]         STREAM     CONNECTED     5893     3551/sshd: samurai
unix  2      [ ]         DGRAM                    5849     3551/sshd: samurai

[/bash]