Created
September 3, 2025 14:38
-
-
Save porfirion/0e66da01c9714b8c06dcd0dd7769d72e to your computer and use it in GitHub Desktop.
List ports
This file contains hidden or 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
| #!/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