A Guide to Kill, Pkill and Killall Commands to Stop the Process in Linux(Kill Process Linux)

The Linux operating system comes with the Kill commands to stop the process(Kill Process Linux). The main change/enables the server to continue the execution of the command without reboot after the update. Linux’s great power has come here, and for this reason, Linux is running on 90% servers, on the planets.

A Guide to Kill, Pkill and Killall Commands to Stop the Process in Linux(Kill Process Linux)

A Guide to Kill, Pkill and Killall Commands to Stop the Process in Linux(Kill Process Linux)

The command sends the command signal, to be more perfect for specific signal processing. Kill command can be executed directly or through shell scripts in a number of ways. Processes using Pkill provide you with some additional features by using the kill command from /usr/bin to destroy the process. The general syntax for the Kill command

itsmarttricks@mangesh:~$ kill [signal or option] PID(s)

The signal name can be for the kill command:

Signal Name		Signal Value			Behaviour

SIGHUP			      1				Hangup
SIGKILL			      9				Kill Signal
SIGTERM			      15			Terminate

Clearly, SIGTERM is the default and safe way to delete processes from behavior. SIGHUP is a less secure way to kill the process as a SIGTERM. SIGKILL is the most unsafe way out of the three above, which processes the process closed.

To kill the process, we need the processing ID of the process. The process is an example of the program. Each time the program starts, a unique PID is automatically generated for that process. Each process in Linux has a pid. The first process to start when Linux system boots is init is processed, so in most cases, it is given a price of ‘1‘. Init is a master process and can not be killed in this way, which claims that master process is not killed accidentally. Init allows the decision to kill and kill itself, where the murder is only requested to be closed. To process all processes and consistently learn their assigned pid, run them.

itsmarttricks@mangesh:~$ ps -A
1 ? 00:00:02 systemd
2 ? 00:00:00 kthreadd
6 ? 00:00:00 mm_percpu_wq
7 ? 00:00:00 ksoftirqd/0
8 ? 00:00:02 rcu_sched
9 ? 00:00:00 rcu_bh
10 ? 00:00:00 migration/0
11 ? 00:00:00 watchdog/0
12 ? 00:00:00 cpuhp/0
13 ? 00:00:00 cpuhp/1
14 ? 00:00:00 watchdog/1
15 ? 00:00:00 migration/1
16 ? 00:00:00 ksoftirqd/1
19 ? 00:00:00 cpuhp/2
20 ? 00:00:00 watchdog/2
21 ? 00:00:00 migration/2
22 ? 00:00:00 ksoftirqd/2
25 ? 00:00:00 cpuhp/3

How To Customize The Output Using Syntax As ‘pidof Process’.

itsmarttricks@mangesh:~$ pidof mysqld
Sample Output
itsmarttricks@mangesh:~$ 1684

Another way to achieve this goal is to follow the syntax below.

itsmarttricks@mangesh:~$ ps aux | grep mysqld
root      1582  0.0  0.0   5116  1408 ?        S    09:49   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql     1684  0.1  0.5 136884 21844 ?        Sl   09:49   1:09 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root     20844  0.0  0.0   4356   740 pts/0    S+   21:39   0:00 grep mysqld

Before we move forward and execute the hit command, note some important points:

  • The user can kill all its processes.
  • The user can not kill another user’s processing.
  • The system can not use the processes used.
  • The root user can kill system-level-processing and the process of any user.

The execution of the ‘Pgrep‘ command is another way to execute this function.

itsmarttricks@mangesh:~$ pgrep mysq
itsmarttricks@mangesh:~$ 3139

To kill the above process PID, use the kill command as shown.

itsmarttricks@mangesh:~$ kill -9 3139

The above command will kill the process of PID = 313 9, where PID is the numerical value process.

Another way to do the same thing can be to re-write.

itsmarttricks@mangesh:~$ kill -SIGTERM 3139

Similarly ‘kill-9 PID’ is to kill ‘kill-SIGKILL PID’ and vice versa.

Also Read – Most Dangerous Windows Commands User Needs to Know

How the killing is being processed using the process name(Kill Process Linux)

Before harming the name of the wrong process and entering the name you need to know the process name.

itsmarttricks@mangesh:~$ pkill mysqld

Kill more than one process at a time.

itsmarttricks@mangesh:~$ kill PID1 PID2 PID3


itsmarttricks@mangesh:~$ kill -9 PID1 PID2 PID3


itsmarttricks@mangesh:~$ kill -SIGKILL PID1 PID2 PID3

If there are too many incidents in the process and many child processes, then you have the ‘killall’ command. This is the only family command, which acts as logic in the process name instead of the process.

itsmarttricks@mangesh:~$ killall [signal or option] Process Name

To kill all mysql events including child processes, use the following commands.

itsmarttricks@mangesh:~$ killall mysqld

Using any of the following commands, you can always check the status of the ongoing process.

itsmarttricks@mangesh:~$ service mysql status
itsmarttricks@mangesh:~$ pgrep mysql
itsmarttricks@mangesh:~$ ps -aux | grep mysql

Also Read – How to install Guake Terminal (Drop-Down Terminal) in Ubuntu 18.04

That’s all, In this article, we have explained the A Guide to Kill, Pkill, and Killall Commands to Terminate a Process in Linux(Kill Process Linux). I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.

Mangesh Dhulap

This is Mangesh Dhulap the Founder and Editor of IT SMART TRICKS have 6+ years of Industrial Experience. We expect from our visitors to like, share, and comment on our posts.

You may also like...

1 Response

  1. pranita says:

    I think it is deep tech knowledge, we have to learn special .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.