Skip to content

Instantly share code, notes, and snippets.

@TomK
Last active February 21, 2023 10:46
Show Gist options
  • Save TomK/b8c5bebe1e29f62d3ecff7e5223c8ff6 to your computer and use it in GitHub Desktop.
Save TomK/b8c5bebe1e29f62d3ecff7e5223c8ff6 to your computer and use it in GitHub Desktop.
What's running on a specified port?
# What's running on a specified port?
# https://gist.github.com/TomK/b8c5bebe1e29f62d3ecff7e5223c8ff6
if [ -z "$1" ]; then
echo 'You must specify a port'
exit 1
fi
PIDS=$(lsof -nP -i:$1 |grep LISTEN |awk '{print $2}')
for PID in $PIDS; do
echo "[$PID] $(ps -p $PID -o command |tail -n1)"
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment