Thứ Hai, 17 tháng 2, 2020

How to kill a process on a specific port on linux

How to kill a process on a specific port on linux
How to kill a process on a specific port on Linux

If you want to kill a process running on port number 8080 then first you need to find the 8080 port process identification number(PID) and then kill it. Run the following command to find 8080 port number PID:
sudo lsof -t -i:8080
Here,
  • sudo - command to ask admin privilege(user id and password).
  • lsof - list of files(Also used for to list related processes)
  • -t - show only process ID
  • -i - show only internet connections related process
  • :8080 - show only processes in this port number
So you can now easily kill your PID using the following command:
sudo kill -9 <PID>
Here,
  • kill - command to kill the process
  • -9 - forcefully
You can use one command to kill a process on a specific port using the following command:
sudo kill -9 $(sudo lsof -t -i:8080)
For more, you can see the following link How to kill a process on a specific port on Linux
From https://stackoverflow.com/a/50411366
Previous Post
Next Post

post written by:

0 nhận xét: