Skip to content

Instantly share code, notes, and snippets.

@jziggas
Forked from tasermonkey/listening.sh
Created April 4, 2023 14:38
Show Gist options
  • Select an option

  • Save jziggas/84540732c402516d76341fb2800d74e1 to your computer and use it in GitHub Desktop.

Select an option

Save jziggas/84540732c402516d76341fb2800d74e1 to your computer and use it in GitHub Desktop.
Listening
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.
@jziggas
Copy link
Copy Markdown
Author

jziggas commented Apr 4, 2023

thanks james

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment