Find and Remove Rogue Processes (bash)

I have a couple of helper function I have put in my ~/.bash_profile that make it easy to find and remove a server thats listening on a specific port:

findserver() { lsof -sTCP:LISTEN -i"$@"; }
killserver() { kill "${@:2}" $(findserver "$1" -t); }

This lets me go killserver :5000 to find and kill the server on that port.


Oh, thanks for sharing this, I’m stealing this for my own collection :slight_smile:


No problem! I got it from one of my friends (@texastoland on Twitter) .dotfile’s repo on github:

1 Like