DEV Community

Cover image for How to Terminate a process in CLI
Baransel
Baransel

Posted on • Originally published at baransel.dev

How to Terminate a process in CLI

Sign up to my newsletter for more tutorials!.

If there is a program that is not responding, you can manually terminate the program by using the kill command. This command will send a specific signal to the unresponsive application and instruct the application to terminate itself.

There are forty-six signals in total that you can use, but generally these two signals are used:

  • SIGTERM (15) — prompts a program to stop running and gives it some time to save its state. If you do not specify the signal when entering the kill command, this will be used.

  • SIGKILL (9) — forcibly terminates process immediately. You lose the unsaved state.

Apart from knowing the signals, you also need to know the process identification number (PID) of the program you want to terminate. If you do not know the PID, run the ps ux command.

Note: To search directly for a process, you can use grep: ps ux | grep <process name>

After making sure you know which signal to use and the PID of the program, enter the following syntax:

kill -<signal> <PID>
Enter fullscreen mode Exit fullscreen mode

Latest comments (1)

Collapse
 
amirgull profile image
amirali

Ctrl + C