Skip to content

Instantly share code, notes, and snippets.

@banjeremy
Created October 12, 2021 22:20
Show Gist options
  • Save banjeremy/88870e61cde5c1b5f50e53ba5df483a3 to your computer and use it in GitHub Desktop.
Save banjeremy/88870e61cde5c1b5f50e53ba5df483a3 to your computer and use it in GitHub Desktop.
Find what process is using a port
whatsonport () {
if [ $# -eq 1 ]
then
lsof -i :$1 | awk '{ print $2; }' | head -n 2 | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} -v PID
else
echo "Usage: whatsonport [port]"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment