Andrei bio photo

Andrei

Linux engineer, devops enthusiast and sys-admin/developer hybrid

Email LinkedIn Github

Overview

Command

Note: The below command shows ALL open ports on a Linux machine, not only ports that are awaiting connections(LISTENING). This includes random high-number souce ports assigned locally when a conection is established with a remote server(ESTABLISHED).

declare -a array=($(tail -n +2 /proc/net/tcp|cut -d":" -f"3"|cut -d" " -f"1"))\
&& for port in ${array[@]}; do echo $((0x$port)); done