Sobes.tech
Senior

How to stop a running process in Linux?

sobes.tech AI

Answer from AI

There are several ways to stop a running process in Linux:

  1. Find the PID (process ID) using the command:
ps aux | grep process_name
  1. Use the kill command to send a termination signal:
kill PID

By default, the SIGTERM (15) signal is sent, which properly terminates the process.

  1. If the process does not terminate, you can send the SIGKILL (9) signal:
kill -9 PID
  1. For convenience, you can use pkill by process name:
pkill process_name
  1. Also, killall terminates all processes with the specified name:
killall process_name

It is important to use SIGKILL only if other signals do not work, as it does not give the process a chance to properly release resources.