Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created November 13, 2013 19:43
Show Gist options
  • Save greyaperez/7455121 to your computer and use it in GitHub Desktop.
Save greyaperez/7455121 to your computer and use it in GitHub Desktop.
What App is using a specific port. Both linux and cygwin versions included.
# LINUX (TODO)
function whoisport (){
port=$1
pidInfo=$(fuser $port/tcp 2> /dev/null)
pid=$(echo $pidInfo | cut -d':' -f2)
ls -l /proc/$pid/exe
}
# CYGWIN
function whoisport (){
echo "Searching ..."
tcpInfo=$(netstat -anob | grep '0.0.0.0:'$1' ' )
echo -e "===================\nTCP INFO:\n===================\n$tcpInfo\n===================\n"
pid=${tcpInfo##* }
pidInfo=$(ps -W | grep $pid)
echo -e "===================\nPID INFO:\n===================\n$pidInfo\n===================\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment