Skip to content

Instantly share code, notes, and snippets.

@zwhitchcox
Created June 11, 2018 13:06
Show Gist options
  • Save zwhitchcox/dc05e89567c0bdb1e50a59c8c6873796 to your computer and use it in GitHub Desktop.
Save zwhitchcox/dc05e89567c0bdb1e50a59c8c6873796 to your computer and use it in GitHub Desktop.
Force kill process by port in one command
#!/bin/bash
# force kill process by port
# Usage: "force-kill PORT"
sudo netstat -tulnp | grep "$1" | sed -r -e "s/.*LISTEN\\s+([0-9]+).*/\1/" | xargs sudo kill -9
@Winona-Ryder
Copy link

@zwhitchcox, I think this is the same thing as fuser $PORT/tcp --kill except without the usual shellscript bugs or need for sudo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment