I am trying to kill a process in the command line for a specific port in ubuntu.
If I run this command I get the port:
sudo lsof -t -i:9001
kill -9 $(lsof -t -i:9001)
can be used to kill the process. You can use any port number instead of 9001
To kill on port service in ubuntu, Enter the below command in terminal
In Terminal :
sudo fuser -k port/tcp
sudo fuser -k 8001/tcp
Kill PORT:
sudo
is important to show process id.
$ sudo netstat -antlp | grep 45136
tcp 0 0 0.0.0.0:45136 0.0.0.0:* LISTEN **-**
$ kill -9 45136
sudo kill $(sudo lsof -t -i:1337)
You want to use backtick not regular tick:
sudo kill -9 `sudo lsof -t -i:9001`
If that doesn't work you could also use $()
for command interpolation:
sudo kill -9 $(sudo lsof -t -i:9001)
Use this for killing process which is running on port number "9001"
kill $(lsof -t -i:9001)