Skip to content

Instantly share code, notes, and snippets.

@christianromney
Last active July 10, 2019 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianromney/a02e40c30f0b93b0cb132fa3d0fd5f8d to your computer and use it in GitHub Desktop.
Save christianromney/a02e40c30f0b93b0cb132fa3d0fd5f8d to your computer and use it in GitHub Desktop.
Who's listening on your machine?
#!/usr/bin/env bash
echo "The following programs are listening for incoming connections:"
lsof -i | grep LISTEN | awk '{print $1}' | sort | uniq | while read x; do
printf "%10s \n\t %s" "$x" (psgrep $x | sed 1d | awk '{print $11}' | sort | uniq); printf "\n\n"
done
#!/usr/bin/env fish
echo "The following programs are listening for incoming connections:"
lsof -i | grep LISTEN | awk '{print $1}' | sort | uniq | while read x
printf "%10s \n\t %s" "$x" (psgrep $x | sed 1d | awk '{print $11}' | sort | uniq); printf "\n\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment