How to Kill Process in Linux
Table of Contents
Kill Process in Linux
Whenever an application becomes unresponsive and gets crashed unexpectedly. If you are trying to start that application again then it won’t start because application process not completely closed at such time you should kill the application process. Then the application will start again easily. In this tutorial, we are going to learn how to kill the process in Linux by using
Basic Syntax For kill and killall
killall commands are used to terminate the processes. The main difference is that
kill command terminates the process with process id while
killall command terminates the process with process name.
The basic syntax for kill command is given below:
kill [SIGNAL] pid
SIGNAL: the following signals will be sent to the processes after executing the command. While you can check all the signals running
kill -l command.
- -HUP (1): restart the process
- -KILL (9): kill the process
- -TERM (15): gracefully stop the process (the default signal)
The basic Syntax for killall command is given below:
killall [ -Z CONTEXT ] [ -u USER ] [ -y TIME ] [ -o TIME ] [ -eIgiqrvw ] [ -s SIGNAL | -SIGNAL ] NAME
where excluding NAME all other arguments are optional
- -Z CONTEXT: kill the only process(es) having context (must precede other arguments
- -u USER: kill only process(es) running as USER
- -y TIME: kill processes younger than TIME
- -o TIME: kill processes older than TIME
- -eIgiqrvw : These are the group of commands.
- -s SIGNAL: send this signal instead of SIGTERM
How to kill process with
kill command is used to terminate the process with process id called PID. To get PID of a process you can use commands like pidof, ps etc. Then by using PID of a process, you can kill the processes.
For example, if you want to get the process id of
vlc media player then you can run the following command.
The output should look like:
vlc process using the
Similarly, if you want to check process id for
Google Chrome the run following command.
You will get output like following
6470 6455 6324 6283 6269 6255 6224 6191 6171 6038 6009 5996 5995 5994 5985 5984 5979 5971 5964 5959 5944 5799 5667 5642 5640 5528
To terminate all of above process run below command:
kill -9 6470 6455 6324 6283 6269 6255 6224 6191 6171 6038 6009 5996 5995 5994 5985 5984 5979 5971 5964 5959 5944 5799 5667 5642 5640 5528
How to kill the process with killall command
killall terminates all the processes that match with the given name. You can kill the processes without getting process id.
Now to kill the process
vlc typing following command and hit
ENTER in terminal:
Similarly to kill
Google chrome process run below command:
You have successfully learned how to kill process in Linux. If you have any queries regarding this then please don’t forget to comment below.
How to Install Apache on Debian 10
How to Turn On Syntax Highlighting in Vim/Vi Editor
How to Install PhpStorm on CentOS 7
How Install Redis on CentOS 8
How to Install MySQL on Linux Mint 19
How to Install Postman on Ubuntu 18.04
How to Install Postman on Manjaro 18
How to Install Anaconda on Ubuntu 18.04
How to Install Anaconda on CentOS 7
How to install LAMP stack on CentOS 7
How to Disable SELinux on CentOS 8
How to Search and Replace Text in Vim or Vi