Skip to content

Instantly share code, notes, and snippets.

@lislon
Created October 19, 2016 12:24
Show Gist options
  • Save lislon/5193299267eeb38ab493bfc2985887ca to your computer and use it in GitHub Desktop.
Save lislon/5193299267eeb38ab493bfc2985887ca to your computer and use it in GitHub Desktop.
# Shows who is listening port $1 with process info
who-listen() {
exec 3<&1 # new pipe to show output of nestat in stdout
# Netstat and then ps -p of process that netstat showed to us
sudo netstat -tulpn | grep :$1 >&3 3>&- | grep -P -o '\d+(?=/)' | sort -u | xargs -r ps -up
exec 3>&- # close pipe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment