Skip to content

Functions

Find the Service running in a specified Port

whoseport() {
local PORT=$1   # Port to check
local SOCKET=`netstat -an | grep $PORT | awk '{print $4}'`
if [ -z "$SOCKET" ]; then
echo "Port $PORT is not in use"
else
echo "Port $PORT is in use by process $SOCKET"
fi
}

Example:

whoseport 8080