Open Linux port with one command

October 3, 2016 21920 point heat 0 liked it 1 comment

View only the listening IPv4 port

 netstat -lnt | awk 'NR>2{print $4}' | grep -E '0.0.0.0:' | sed 's/.*://' | sort -n | uniq

View only listening IPv6 ports

 netstat -lnt | awk 'NR>2{print $4}' | grep -E ':::' | sed 's/.*://' | sort -n | uniq

Both IPv4 and IPv6 are available

 netstat -lnt | awk 'NR>2{print $4}' | grep -E '(0.0.0.0:|:::)' | sed 's/.*://' | sort -n | uniq

If you want to list all the ports listening on the localhost interface, use the following:

 netstat -lnt | awk 'NR>2{print $4}' | grep -E '(127.0.0.1:|::1:)' | sed 's/.*://' | sort -n | uniq

Gcod

Talking about the trivial matters of life and talking about the whole world, that's all

Article review

  • mortgages first

    mortgage services of texas mortgage services mortgage services of texas mortgage servicing

    June 18, 2018