Skip to content

Instantly share code, notes, and snippets.

@porfirion
Created September 3, 2025 14:38
Show Gist options
  • Save porfirion/0e66da01c9714b8c06dcd0dd7769d72e to your computer and use it in GitHub Desktop.
Save porfirion/0e66da01c9714b8c06dcd0dd7769d72e to your computer and use it in GitHub Desktop.
List ports
#!/bin/bash
sudo lsof -i -P \
| grep 'LISTEN' \
| awk 'BEGIN{OFS="\t"; print "COMMAND","PID","USER","FD", "TYPE", "DEVICE", "HOST", "PORT", "DIRECTION"}{ split($9,a , ":"); printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5,$8, a[1], a[2],$10); }' \
| column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment