Last active
February 22, 2023 14:29
-
-
Save nethoncho/161330e9538bbcfae783666c7eeaf230 to your computer and use it in GitHub Desktop.
Raspberry Pi Raspbian list open ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netstat -lnt | grep LISTEN | awk '{ print ( $4 ) }' | awk 'BEGIN{FS=":"} { print $(NF) }' | sort -n | uniq |
This only works for tcp ports. What about udp ports ?
for udp ports :
netstat -lnu | grep udp | awk '{ print ( $4 ) }' | awk 'BEGIN{FS=":"} { print $(NF) }' | sort -n | uniq
$ netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:42217 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::5000 :::* LISTEN tcp6 0 0 :::42217 :::* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::9171 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN
Filtered
$ netstat -lnt | grep LISTEN | awk '{ print ( $4 ) }' | awk 'BEGIN{FS=":"} { print $(NF) }' | sort -n | uniq 22 80 5000 9171 42217
🧡👍👏
-l
already filters listening ports, so we can omit grep LISTEN
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Filtered