Skip to content

Instantly share code, notes, and snippets.

@prochor666
Last active August 14, 2021 09:18
Show Gist options
  • Save prochor666/36358eb4a3b53cd67bd0c6e8bae059d9 to your computer and use it in GitHub Desktop.
Save prochor666/36358eb4a3b53cd67bd0c6e8bae059d9 to your computer and use it in GitHub Desktop.
Check port usage
#!/bin/bash
# @author prochor666@gmail.com
#
# Check port usage
function inUse()
{
if [[ -z $(ss -tulwn | grep -E "LISTEN.*:${@} ") ]];
then
echo "SUCCESS: ${@} is free to use"
else
echo "ERROR: ${@} is used"
fi
}
echo "Check port usage"
echo ""
read -p "Input port: " PORT
inUse $PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment