Another tool available on Linux is ss. From the ss man page on Fedora:
NAME ss - another utility to investigate sockets SYNOPSIS ss [options] [ FILTER ] DESCRIPTION ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state informations than other tools.
Example output below - the final column shows the process binding:
[root@box] ss -ap State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::http :::* users:(("httpd",20891,4),("httpd",20894,4),("httpd",20895,4),("httpd",20896,4) LISTEN 0 128 127.0.0.1:munin *:* users:(("munin-node",1278,5)) LISTEN 0 128 :::ssh :::* users:(("sshd",1175,4)) LISTEN 0 128 *:ssh *:* users:(("sshd",1175,3)) LISTEN 0 10 127.0.0.1:smtp *:* users:(("sendmail",1199,4)) LISTEN 0 128 127.0.0.1:x11-ssh-offset *:* users:(("sshd",25734,8)) LISTEN 0 128 ::1:x11-ssh-offset :::* users:(("sshd",25734,7))
/procfilesystem, you should be able tocat /proc/net/tcpfor tcp connections open. Thelocal_addresscolumn's lowest 4 hex digits are the port. There are similar files forudp,tcp6, and so on.