Skip to content

Instantly share code, notes, and snippets.

@jdiegosierra
Created August 19, 2024 12:53
Show Gist options
  • Save jdiegosierra/eb057e7edaf8ecdf4fed7532767ccba4 to your computer and use it in GitHub Desktop.
Save jdiegosierra/eb057e7edaf8ecdf4fed7532767ccba4 to your computer and use it in GitHub Desktop.
sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment