Skip to content

Instantly share code, notes, and snippets.

@rmarren1
Forked from marcosvidolin/kill_port_process.sh
Created May 1, 2018 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmarren1/41c84a00d4c283eba647fd90d08561df to your computer and use it in GitHub Desktop.
Save rmarren1/41c84a00d4c283eba647fd90d08561df to your computer and use it in GitHub Desktop.
Linux: How to list and kill a process using a port
# to list all ports that are used
sudo netstat -ntlp | grep LISTEN
# you can obtain a specific port using the following command
sudo netstat -ntlp | grep :8080
# when you execute the command above you will see some thing like that
tcp 0 0 0.0.0.0:27370 0.0.0.0:* LISTEN 4394/skype
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 2216/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 4912/cupsd
tcp6 0 0 :::8080 :::* LISTEN 8868/java
tcp6 0 0 ::1:631 :::* LISTEN 4912/cupsd
# to kill the process using the port 8080 see the process number "8868/java" then:
sudo kill -TERM 8868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment