[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJuly 3, 2023

How to kill a process.

How To Kill A Process.

In this article, we will show you how to use kill, killall, and pkill commands to terminate a process.

The main difference between these tools is that kill terminates processes based on Process ID number (PID), while the killall and pkill commands terminate running processes based on their names and other attributes.

 

System Kill Signals.

kill, killall, and pkill send a given signal to specified processes or process groups. When no signal is specified, each tool sends 15 (TERM).

The most commonly used signals are:

  • 1 (-HUP): to reload a process.

  • 9 (-KILL): to kill a process.

  • 15 (-TERM): to gracefully stop a process.

Signals can be specified in three different ways:

  • using a number (e.g., -1)

  • with the “SIG” prefix (e.g., -SIGHUP)

  • without the “SIG” prefix (e.g., -HUP).

Use the -l option to list all available signals:

kill -l  # or killall -l

 

Terminating Processes Using the kill Command

To terminate a process with the kill command first, you need to find the process PID. You can do this using different commands such as top, ps , pidof, and pgrep .

Let’s say the chrome browser has become unresponsive, and you need to kill the browser process. To find the process ID, use the pidof command:

pidof chrome

The command will print all chrome processes:

2551 2514 1963 1856 1771

Once you know the chrome processes PIDs to terminate all of them send the TERM signal:

kill -9 2551 2514 1963 1856 1771

 

Terminating Processes Using the killall Command

The killall command terminates all programs that match a specified name.

Using the same scenario as before, you can kill the chrome process by typing:

killall -9 chrome

killall accepts several options such as sending signals to processes owned by a given user, matching processes names against regular expressions, and the creation time. You can get a list of all options by typing killall (without any arguments) on your terminal.

For example, to terminate all processes running as a user “sara”, you would run the following command:

sudo killall -u sara

 

Terminating Processes Using the pkill Command

pkill terminates processes that match the pattern given on the command line:

pkill -9 chrome

The name of the process doesn’t have to be an exact match.

With pkill you can also send a signal to processes that are owned by a given user. To kill only the chrome processes owned by the user “sara”, you would type:

pkill -9 -u sara chrome

 

Conclusion

Terminating unresponsive programs using the kill, killall and pkill commands is an easy task. You only need to know the process name or PID.

Keep reading
How to use lsof command in Linux.
October 4, 2023

How to use lsof command in Linux.

How To Use Lsof Command In Linux. This article will explain how to use the lsof command in Linux with examples. Introduction The lsof command stands for LiSt Open Files and shows open files and which process uses them. Since Linux sees every object as a file, such as devices, directories, etc.,…

Read article
How to use look command in Linux.
September 15, 2023

How to use look command in Linux.

How To Use Look Command. The look command in Linux shows the lines beginning with a given string. This command also uses binary search if the file is sorted. If file is not specified, the file /usr/share/dict/words is used. And then only the alphanumeric characters are compared and the case of…

Read article
How to use let command in Linux.
September 15, 2023

How to use let command in Linux.

How To Use Let Command. In this tutorial, we will go over the let command syntax, options, and usage examples. Bash let is a built-in command in Linux systems used for evaluating arithmetic expressions. Unlike other arithmetic evaluation and expansion commands, let is a simple command with its own…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00