Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Kill a Process in Linux Systems - DesignLinux

Sep 28 2020
designlinux 0 Comments
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.

Related

Tags: kill, terminal

How to Monitor Apache Performance Using mod_status in Ubuntu

Prev Post

13 Best Photo Image Editors for Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 2
  • 150
  • 559,830

DesignLinux.com © All rights reserved

Go to mobile version