• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to use Kill, Pkill and Killall to Terminate a Process in Linux

{{postValue.id}}

To use Kill, Pkill and Killall Commands to Terminate a Process in Linux

Linux Operating System provides Kill command to terminate a process, which makes it possible to continue running the server without the necessity of reboot after making a major change or update. The kill command can be executed directly or from a shell script in a number of ways. Using kill command from /usr/bin will supply you additional feature to kill a process by process name. Kill, Pkill and Killall Commands to Terminate a Process in Linux are explained in this tutorial.


List of Signal Name for a kill command

Signal name Signal value Behavior
SIGHUP 1 Hangup
SIGKILL 9 Kill Signal
SIGTERM 15 Terminate


SIGTERM is the safest and default way to kill a process. SIGHUP is not a secure way of killing a process as SIGTERM. SIGKILL is the most dangerous way to kill a process that terminates a process without saving.

To kill a process, it is necessary to know the Process ID of a process. Whenever a program begins, automatically an unique PID is created for that process. Run the following command to know all the processes and their assigned pid.

[root@linuxhelp ~]# ps -A
  PID TTY          TIME CMD
    1 ?        00:00:01 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
.
.
.
3913 ?        00:00:00 gnome-pty-helpe
 3914 pts/0    00:00:00 bash
 4632 ?        00:00:00 sleep
 4636 pts/0    00:00:00 ps

To customize the above output

[root@linuxhelp ~]# pidof sleep
3723

or use the following command.

[root@linuxhelp ~]# ps aux | grep sleep
root      3736  0.0  0.0 107892   624 ?        S    20:59   0:00 sleep 60
root      3744  0.0  0.0 112644   956 pts/0    R+   21:00   0:00 grep  --color=auto sleep

To execute a kill command, some important points to be noticed are:

  • A user can kill all the processes.
  • A root user can kill system-level-process and the process of any user.
  • A user cannot kill processes which the System is using.
  • A user cannot kill another user’ s process.

Execute ‘ pgrep‘ command to perform the same function is to .

[root@linuxhelp ~]# pgrep cups
3216

Use the kill command, to kill the above process ID

[root@linuxhelp ~]# kill -9 3216

The above command will kill the process with pid=3216, where PID is a Numerical Value of process. Or use the following command to do the same.

[root@linuxhelp1 Desktop]# pidof cupsd
3875
[root@linuxhelp1 Desktop]# kill -SIGTERM 3875


Killing a process using process name

[root@linuxhelp ~]# pkill nautilus

Be aware of process name before killing.


To Kill more than one process at a time

# kill PID1 PID2 PID3
or
# kill -9 PID1 PID2 PID3
or
# kill -SIGKILL PID1 PID2 PID3

To kill a process that has too many instances and a number of child processes, then use ‘ killall‘ .

Use the below command, to kill all ssh-agent instances with child processes.

[root@linuxhelp ~]# killall ssh-agent

To check the status of the process use the below command:

[root@linuxhelp Desktop]# systemctl status ssh-agent
ssh-agent.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
[root@linuxhelp Desktop]# pgrep ssh-agent

Tags:
daniel
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

how the root can kill a specific process for an user, please can you give me with a scenario.

A

First find the all the processes and Process IDs of particular users by running following command. # ps -aux | grep {user} And then kill the specific process by their process ID’s

Q

how to avoid to kill any process. I mean suppose I do not want anybody to kill mysql service using kill command so how can I do this?

A

if the process was started with root privileged, it can not be killed by any user unless the user is sudoers.

Q

Can you please tell how to kill all the process running when i close the terminal/screen

A

i Didn’t get you question. When you close a terminal. All the running processes gets killed except those running in background and you can kill those by finding their pid.

Q

great tutorial . Am newbie to linux this tutorial help me lot . Thanks

A

you are welcome . Follow us

Q

killall: command not found help me with it

A

please install FOR (Ubuntu / Debian): #apt-get install psmisc For RHEL – Red Hat / Fedora: #yum install psmisc

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.