• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Kill a Process in Linux Systems

Written by Admin, Updated On September 28, 2020
kill, terminal
How to Kill a Process in Linux

Sometimes, in your system some applications becomes unresponsive and unexpectedly crashes. Even after starting again it will not work because of the application process not shuts down completely. In such situation, you need to stop or terminate the process or kill the application process. In Linux, you can kill the process using multiple ways. This article shows you how to use kill commands to terminate a process in Linux.

System Kill Signals#

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

Below are most used signals:

  • 1 (-HUP): to reload a process.
  • 9 (-KILL): to kill a process.
  • 15 (-TERM): to gracefully stop a process.

You can specify the signals by three different ways:

  • using a number (e.g., -1)
  • with the “SIG” prefix (e.g., -SIGHUP)
  • without the “SIG” prefix (e.g., -HUP).

To list the all available signals use -l option with kill command:

kill -l # or killall -l

Terminate Process Using kill Command#

To use the kill command, first you need the process PID. You can find PID using the top, ps, pidof or pgrep command.

For example, if your Google Chrome browser is unresponsive and you want to kill the process. You should first find the PID of Google Chrome using the pidof command:

pidof google-chrome

It show all the all Chrome processes:

3551 2010 1920 1845

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

kill -9 3551 2010 1920 1845

Terminate Process Using killall Command#

The killall command is useful when you want to kill all the processes of specified program.

For previous example, you can kill the Chrome processes by below command:

killall -9 google-chrome

You also can pass the several option along with killall command, like sending signals to processes owned by a given user, matching processes names against regular expressions, and the creation time. To get the list of all options of the killall command, run the killall command without any option.

For instance, if you want to terminate all processes running for a user tecnstuff, you just need to type as following:

sudo killall -u tecnstuff

Terminating Processes Using pkill Command#

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

pkill -9 google-chrome

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

You also can send the signal with pkill command to the processes of a specified user. To kill only the chrome processes owned by the user tecnstuff, you would type:

pkill -9 -u tecnstuff google-chrome

Conclusion#

When some application becomes unresponsive you can terminate using the kill, killall and pkill commands. You just need to find the PID or process name.

If you have any question or feedback, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Mount Windows Share on Linux using CIFS
Next Article   How to Find the Length of a List in Python

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook