Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.12 KB

kill-process-running-on-port-linux.md

File metadata and controls

61 lines (43 loc) · 1.12 KB
title description date draft tags categories featuredImage featuredImagePreview toc
Kill process running on a port - Linux
Kill process running on a port - Linux
2023-03-24 16:25:46 +0530
false
linux
terminal
process
Linux
/ps-linux.webp
/ps-linux.webp
enable auto
false
true



As an instance, to kill all the process running on TCP port 8000, use the below command to detect the process id:

sudo lsof -i TCP:8000

And now kill it with its pid:

kill -9 <pid_value>

Certain processes like mysqld and apache2 might restart after you have killed them using the above commands. Even if you use the killall command, they will still appear after some time.

In such cases, I advise you to use application specific commands to stop a service. For example, to kill the Apache process on Ubuntu, use the command:

sudo systemctl stop mysqld

Extra

See a list of Top process that using the most memory or CPU or disk:

top
htop

Search a running process:

ps -ef | grep firefox
pgrep firefox