Linux Commands

How to Use killall and kill Commands to Stop Processes on Linux

If the process in the Linux system becomes unresponsive and takes too long to respond you might need to kill it. When an application fails to close on your Linux system it keeps using the processing power and the memory. In Linux, you can terminate the process using different utilities. The kill and killall commands are the most powerful and most used commands for this in Linux.

killall and kill commands are used to terminate the running applications on the system. These commands terminate the processes by taking the name or process ID as an argument. Let’s discuss the two distinct Linux kill and killall commands.

What is killall Command in Linux

killall is the Linux tool used to terminate the running process based on the name of the process and its attributes. This tool terminates the running application forcefully. It is the easiest method of killing all the processes in Linux. It will send a TERM signal by default; here is the syntax for using it:

killall <process-name>

What is kill command

The kill command is the shell command which terminates the process based on the process ID.

Use killall and kill commands to stop processes on Linux, here is the syntax for using it:

kill -15 <PID>

How to Use killall Command on Linux to Stop Processes

The ps aux is the simplest way of getting the complete overview of the currently running processes:

ps aux

The killall command is used to close all the running processes by name by sending the SIGTERM signals. For illustration here I have killed a player called Hypnotix using the killall syntax stated previously:

killall hypnotix

How to Use kill Command on Linux to Stop Processes

To terminate the process via the kill command you first need to find the process ID. The ps aux command returns the list or running processes with their PIDs. The following Linux command returns the process ID of the specific process:

pgrep <process name>

To get the process ID of Hypnotix use the below command:

pgrep hypnotix

kill command kills the process by taking a process ID. The kill command in Linux does not terminate the running process directly, it sends the SIGTERM signals to the application. The SIGTERM is the gentle way of terminating the process. Here -15 is the SIGTERM signal for terminating the process.

To kill the hypnotix process with -15 SIGTERM, use:

kill -15 3232

Bottom Line

When the process is Linux cannot be closed manually, you can terminate it via the command line. To terminate the process, you must find running processes and their Process ID using the ps aux and pgrep commands. After finding the IDs use the kill and killall commands in the terminal on Linux. The killall is the Linux tool that ends the session of the process based on name and the kill command exits the by taking the process ID as an argument.

About the author

Zainab Rehman

I'm an author by profession. My interest in the internet world motivates me to write for Linux Hint and I'm here to share my knowledge with others.