DEV Community

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

Posted on • Originally published at baransel.dev

5 4

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
amirgull profile image
amirali

Ctrl + C

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay