Skip to content

Instantly share code, notes, and snippets.

@alismx
Last active April 7, 2023 20:34
Show Gist options
  • Save alismx/ce30489841fdedc021675981308a399e to your computer and use it in GitHub Desktop.
Save alismx/ce30489841fdedc021675981308a399e to your computer and use it in GitHub Desktop.
Bash function to check what is running on a specified port.
# load into your path and run `whatisonport 5432`
whatisonport() {
echo "lsof results - "
echo "$(sudo lsof -i :$1)"
echo " "
echo "fuser results - "
echo "$(sudo fuser $1/tcp)"
echo " "
echo "netstat results - "
echo "$(sudo netstat -ltnp | grep -w :$1)"
echo " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment