Here are a few ways to list open ports in the linux terminal.
First we'll try lsof.
$ lsof -i
example:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
kdeconnec 1671 john 10u IPv6 27671 0t0 UDP *:1716
kdeconnec 1671 john 11u IPv6 27672 0t0 TCP *:1716 (LISTEN)
thunderbi 1712 john 36u IPv4 28601 0t0 TCP Arach:46604->mail.com:imap2 (ESTABLISHED)
thunderbi 1712 john 50u IPv4 25417 0t0 TCP Arach:46694->mail.com:imap2 (ESTABLISHED)
thunderbi 1712 john 51u IPv4 25418 0t0 TCP Arach:46696->mail.com:imap2 (ESTABLISHED)
thunderbi 1712 john 65u IPv4 871420 0t0 TCP Arach:48490->mail.com:imap2 (ESTABLISHED)
thunderbi 1712 john 80u IPv4 1690593 0t0 TCP Arach:49032->mail.com:imap2 (ESTABLISHED)
java 2342 john 99u IPv6 38225 0t0 TCP localhost:40834->localhost:4243 (ESTABLISHED)
firefox 3757 john 49u IPv4 1809675 0t0 TCP Arach:58736->fra16s08-in-f206.1e100.net:https (ESTABLISHED)
firefox 3757 john 61u IPv4 1809667 0t0 TCP Arach:35190->fra07s28-in-f238.1e100.net:https (ESTABLISHED)
firefox 3757 john 62u IPv4 1816763 0t0 TCP Arach:43806->cache.google.com:https (ESTABLISHED)
firefox 3757 john 63u IPv4 1809767 0t0 TCP Arach:59834->webcluster-ssl2.webpod5-cph3.one.com:https (ESTABLISHED)
firefox 3757 john 66u IPv4 1816252 0t0 TCP Arach:35992->fra16s07-in-f10.1e100.net:https (ESTABLISHED)
firefox 3757 john 69u IPv4 1779531 0t0 TCP Arach:55194->192.0.73.2:https (ESTABLISHED)
And here's using netstat
$ netstat -lptu
example:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 Arach:domain *:* LISTEN -
tcp6 0 0 [::]:4242 [::]:* LISTEN -
tcp6 0 0 localhost:4243 [::]:* LISTEN -
tcp6 0 0 [::]:1716 [::]:* LISTEN 1671/kdeconnectd
udp 0 0 *:mdns *:* -
udp 0 0 *:56013 *:* -
udp 0 0 Arach:domain *:* -
udp 0 0 *:bootpc *:* -
udp 0 0 *:ipp *:* -
udp6 0 0 [::]:1716 [::]:* 1671/kdeconnectd
udp6 0 0 [::]:36429 [::]:* -
udp6 0 0 [::]:mdns [::]:* -
And finally using netstat showing port numbers instead of service names
$ netstat -lptun
example:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN -
tcp6 0 0 :::4242 :::* LISTEN -
tcp6 0 0 127.0.0.1:4243 :::* LISTEN -
tcp6 0 0 :::1716 :::* LISTEN 1671/kdeconnectd
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 0.0.0.0:56013 0.0.0.0:* -
udp 0 0 127.0.1.1:53 0.0.0.0:* -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
udp 0 0 0.0.0.0:631 0.0.0.0:* -
udp6 0 0 :::1716 :::* 1671/kdeconnectd
udp6 0 0 :::36429 :::* -
udp6 0 0 :::5353 :::* -
Related Posts
Categories
Linux Snippets