Skip to content

Instantly share code, notes, and snippets.

@jdstapleton
Created September 3, 2014 23:33
Show Gist options
  • Save jdstapleton/363e609605b8db9071a0 to your computer and use it in GitHub Desktop.
Save jdstapleton/363e609605b8db9071a0 to your computer and use it in GitHub Desktop.
listening.sh
# Mac OSX:
listening () {
lsof -Pni | grep '(LISTEN)' | awk 'BEGIN {printf "%-15s %5s %21s\n", "Command", "PID", "PORT"} {printf "%-15s %5s %21s\n", $1,$2,$9}'
}
# Linux (if you want non-you processes that are listening):
listening () {
sudo lsof -Pni | grep '(LISTEN)' | awk 'BEGIN {printf "%-15s %5s %21s\n", "Command", "PID", "PORT"} {printf "%-15s %5s %21s\n", $1,$2,$9}'
}
# For linux you can copy the function into a new file called(or any other name): /etc/profile.d/listening.sh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment