How to Kill a Process in Linux (2023 Guide)

We’ve got all had these days when our laptop runs exceptionally sluggish and stutters in performing even the essential duties. In Home windows, you solely have the Home windows Process Supervisor to examine and kill processes that aren’t so necessary however eat huge quantities of reminiscence. Nonetheless, in Linux, you will have a whole arsenal … The post How to Kill a Process in Linux (2023 Guide) appeared first on Ferdja.

May 5, 2023 - 17:00
How to Kill a Process in Linux (2023 Guide)

We’ve got all had these days when our laptop runs exceptionally sluggish and stutters in performing even the essential duties. In Home windows, you solely have the Home windows Process Supervisor to examine and kill processes that aren’t so necessary however eat huge quantities of reminiscence. Nonetheless, in Linux, you will have a whole arsenal of instructions and GUI instruments to handle these duties. On this article, we are going to present some simple command line (CLI) strategies in addition to GUI strategies for learn how to kill a course of in Linux.

Terminate Course of in Linux (2023)

However earlier than we dive into the world of course of administration in Linux, allow us to perceive what precisely a course of is and what’s a course of ID in Linux methods.

What are Processes in Linux

In Linux, every at the moment operating occasion of a program is called a “course of,” whereas every executable file is called a program. When any program is executed, a course of is created and every course of is assigned a novel 5-digit identification quantity generally known as “course of ID”. When a course of has completed executing or is terminated forcefully, its course of ID will get assigned to the next-in-the-line course of.

Kill Course of by way of Command Line in Linux

Although utilizing the terminal might generally appear intimidating as in comparison with utilizing GUI instruments for primary duties, managing numerous processes turns into a lot simpler when you get a grasp of the instructions and their numerous choices.

Termination Indicators

If you attempt to kill a course of both from the GUI or the CLI in Linux, the kernel sends a termination sign to the method. The method acts accordingly, relying upon the sign obtained. Every of those indicators is assigned a selected quantity for this system to know shortly. There are quite a few sorts of termination indicators, however we have now defined solely the important ones right here:

Sign Numeric Worth Description
SIGHUP 1 It stands for ‘Sign Hangup’
It’s despatched when the terminal is closed.
SIGINT 2 It stands for ‘Sign Interrupt’
It’s despatched when the consumer terminates the method.
SIGKILL 9 It stands for ‘Sign Kill’
It’s despatched when you must stop a course of instantly
SIGTERM 15 It stands for ‘Sign Termination’
It’s despatched when you must terminate a course of and launch the assets consumed
SIGSTOP 19 – for ARM, x86
17 – for ALPHA
23 – for MIPS
24 – for PA-RISC
It stands for ‘ Sign Cease’
It’s despatched when you must pause a course of and resume it later
Essentially the most generally used indicators are the SIGKILL (9) and the SIGTERM (15).

Determine the Course of IDs

Earlier than you terminate a course of, you must know some particulars of the method similar to the method ID, operating time, and so forth. To know the main points of a course of, use the ps command:


With the ps command, you must seek for the method by scrolling and noting its title, which may very well be cumbersome. As an alternative, you’ll be able to even use the grep command with the ps command in a pipeline, as proven beneath:

ps | grep

To make issues easier, there’s a separate command that reveals solely the method ID of any operating course of you must know. The syntax to make use of the pidof command is:


Identifying the process id

Terminate Course of utilizing the kill Command

After getting famous the method ID of the method you need to terminate, the most typical command used to terminate applications in your Linux system is the kill command. The syntax to make use of the kill command is:


The parameter is optionally available and the kill command sends the SIGTERM (15) sign by default. You’ll be able to ship some other sign by its numerical worth or the precise sign title from the desk above.

terminate using kill command

Terminate Course of utilizing the pkill Command

Should you really feel that looking for course of id is inconvenient, you should use the pkill command. It appears to be like for the processes matching a sample after which kills it. The syntax to make use of the pkill command is:


A few of the widespread choices to pair with the pkill command are:

Possibility Description
-n Selects solely the newest processes matching the method id
-u Selects the processes owned by a specific consumer
-x Selects processes matching the sample precisely

That is notably necessary when a number of customers are engaged on completely different situations of the identical program in the identical system and one of many situations begins to have some sudden conduct. For instance, within the beneath screenshot, we’re killing the “gedit” occasion owned by the consumer ‘intel’ utilizing the pkill command in Linux:

pkill -u intel gedit

Kill gedit process using pkill command

Terminate Course of utilizing killall Command

The killall command works equally to the kill command but it surely kills all of the processes matching the method title regardless of the consumer. By default, it sends the SIGTERM sign if not specified in any other case. An attention-grabbing factor to notice is that the killall command can by no means kill itself however can terminate different situations of the killall command. The syntax to make use of the killall command is:


A few of the choices to pair with the killall command are:

Possibility Description
-r Interprets the process_name as a regex sample after which kills the processes matching the sample
-u kills the desired course of owned by a specified proprietor.
-o Kills the desired processes older (began earlier than) than a selected time.
-y Kills the desired processes youthful (began after) the precise time.

The killall command will be helpful to terminate a collection of the identical course of and even all of the processes owned by a selected proprietor. Right here in our instance, we’re killing all of the processes of “sleeping for 500 seconds” utilizing the killall command in Linux:

killall -v sleep

kill all processes named sleep

Terminate Linux Course of utilizing high/ htop Command

This technique of killing processes is helpful when you haven’t any clue which processes are consuming max assets. In each instructions, you’ll be able to navigate by means of all of the operating processes and even zombie processes and may finish them shortly. To make use of the highest command to observe your assets, use the syntax within the Terminal:


Understanding the Output:

The primary output of the highest command is split into columns that are:

  1. PID – reveals the method ID of the operating course of
  2. Person – reveals the proprietor of the method
  3. PR – reveals the precedence worth of the method which is assigned by the working system
  4. NI – reveals the good values that are like assigning user-spaced values to manually management the precedence of a activity.
  5. VIRT – reveals the quantity of digital reminiscence utilized by the method.
  6. RES – reveals the quantity of bodily reminiscence utilized by the method
  7. SHR – reveals the quantity of reminiscence shared by different processes
  8. S – reveals the present state of the method which will be:
    • D – uninterruptible sleep
    • R – operating
    • S – sleeping
    • T – stopped
    • Z – zombie
  9. %CPU – Reveals the quantity of CPU utilized by the method in share
  10. %MEM – Reveals the quantity of RAM utilized by the method in share
  11. TIME+ – Reveals the entire operating time of the method
  12. Command – Reveals which command was invoked for the method.

Should you don’t know the method ID of the duty you need to kill, both navigate by means of the listing utilizing the arrow keys or seek for the method title within the course of desk in Linux.

To go looking the method title, press ‘L’ on the keyboard and sort within the course of title you need to search. As soon as you discover the nefarious course of, press ‘ok’ on the keyboard to kill the method. Now, enter the method ID or depart it on the at the moment highlighted course of and press ‘ENTER’. Subsequent, enter the termination sign after which press ‘ENTER’ to kill this system. To return again to the terminal, press ‘q’ on the keyboard.

Though the high command reveals particulars similar to course of ID, reminiscence consumption, and extra for all of the operating processes, it isn’t properly fitted to inexperienced persons because it doesn’t present any key mappings or learn how to use it. Then again, the htop command has a extra user-friendly interface, even for a command line device. Plus, it reveals all the main points in a separate view, therefore, it doesn’t muddle the terminal window. It doesn’t come preinstalled in most distros, and you must use the next command to put in htop in Linux:

sudo apt set up -y htop

To make use of htop to handle processes in Linux, use the command beneath:


To kill a program, navigate to the method title you need to terminate, press ‘F9’ after which press Enter. If you must search and kill any program, press ‘F3’ on the keyboard, sort within the title and hit Enter. The course of title might be highlighted, press F9 after which press Enter on the keyboard to terminate the method.

  • How to Kill a Process in Linux
  • How to Kill a Process in Linux

Kill a Course of by way of System Monitor in Linux

Should you really feel that the command line technique is troublesome for you, you should use the built-in system monitor device that’s out there on each Linux distribution. To study the way it works, open the system monitor device from the Purposes menu and comply with the steps beneath.

1. As soon as the system monitor device opens, you will note three tabs on high named — Processes, Sources, and File System. To handle your processes, head over to the “Processes” tab. Right here, you will note your entire at the moment operating processes. Press ‘CTRL+F’ to seek for a course of title. Click on on the method title you need to terminate and click on on “Finish Course of”.

Search for process using system monitor

2. Then, you’ll get a affirmation immediate whether or not you need to finish the method or not. Go forward and click on on the massive crimson “Finish Course of” button to kill the method in Linux.

kill process using system monitor

Often Requested Questions

How do I cease all processes in Linux?

If you must cease all processes (besides the login shell, init, and kernel-specific processes) for a selected consumer in Linux, use both the pkill command or the killall command as per the syntax:

pkill -u

killall -u

If you must kill each course of for each consumer together with the init system, press the ‘ALT + Prt Sc + o’ keys on the keyboard.

Is it OK to finish a course of?

If you shut any non-essential background course of or a consumer course of that’s consuming numerous system reminiscence, you liberate the assets which now will be utilized by different processes. However, earlier than shutting down any course of, just remember to’re not killing a vital working system course of.

What are the background processes in Linux?

In Linux, background processes are processes that may run with out the shell occasion or any consumer intervention. They are often considered utilizing any of the instructions – high, htop, ps, and so forth.

What’s a zombie course of?

A course of that has been killed by the consumer however remains to be occupying reminiscence is called a zombie course of.

What does CTRL + Z do in Linux?

If you use CTRL + Z in Linux, it sends the SIGTSTP sign which suspends the method and sends it within the background. When a course of is in a suspended state within the background, you can’t kill the method till it’s introduced again into the foreground.

Kill Processes in Linux Simply

Killing reminiscence hogging processes is sort of an important activity that each consumer ought to study. On this article, we have now proven each the command line technique, together with instructions like killall and pkill, in addition to the GUI strategies to kill processes in Linux. We’ve got even detailed learn how to use widespread instruments like high and htop to handle processes in your Linux PC. Should you face any points whereas utilizing these instruments to kill a course of, do tell us within the feedback beneath.

The post How to Kill a Process in Linux (2023 Guide) appeared first on Ferdja.