Kill Command in Linux
We hope this post helped you to find out Kill Command in Linux
Linux is a good and superior working system, however it isn’t good. On occasion, some purposes could begin behaving erratically and turn into unresponsive or begin consuming a number of system assets. Unresponsive purposes can’t be restarted as a result of the unique utility course of by no means shuts down utterly. The one answer is to both restart the system or kill the appliance course of.
There are a number of utilities that will let you terminate errant processes with
kill the being essentially the most generally used.
kill Command #
kill is a shell builtin in most Bourne-derived shells akin to Bash and Zsh. The command conduct is barely totally different between the shells and the standalone
type command to show all areas in your system containing
type -a kill
kill is a shell builtin kill is /bin/kill
The output above tells that the shell builtin has precedence over the standalone executable, and it’s used everytime you sort
kill. If you wish to use the binary, sort the complete path to the file
/bin/kill. On this article, we are going to use the Bash builtin.
The syntax of the
kill command takes the next type:
kill command sends a sign to specified processes or course of teams, inflicting them to behave in line with the sign. When the sign will not be specified, it defaults to
Essentially the most generally used alerts are:
HUP) – Reload a course of.
KILL) – Kill a course of.
TERM) – Gracefully cease a course of.
To get an inventory of all accessible alerts, invoke the command with the
Alerts could be laid out in three other ways:
- Utilizing quantity (e.g.,
- Utilizing the “SIG” prefix (e.g.,
- With out the “SIG” prefix (e.g.,
The next instructions are equal to 1 one other:
kill -1 PID_NUMBER
kill -SIGHUP PID_NUMBER
kill -HUP PID_NUMBER
The PIDs supplied to the
kill command could be one of many following:
PIDis larger than zero, the sign is shipped to the method with ID equal to the
PIDis the same as zero, the sign is shipped to all processes within the present course of group. In different phrases, the sign is shipped to all processes belonging to the GID of the shell that invoked the
ps -efjcommand to view the method group IDs (GIDs).
PIDis the same as
-1, the sign is shipped to all processes with the identical UID because the consumer invoking the command. If the invoking consumer is root, the sign is shipped to all processes besides init and the
killcourse of itself.
PIDis lower than
-1, the sign is shipped to all processes within the course of group eq with GID equal to absolutely the worth of the
Common customers can ship alerts to their very own processes, however not people who belong to different customers, whereas the foundation consumer can ship alerts to different consumer’s processes.
Terminating Processes Utilizing the
kill Command #
To terminate or kill a course of with the
kill command, first you should discover the method ID quantity (PID). You are able to do this utilizing totally different instructions akin to
Let’s say the Firefox browser has turn into unresponsive, and you should kill the Firefox course of. To seek out the browser PIDs use the
The command will print the IDs of all Firefox processes:
6263 6199 6142 6076
As soon as the processes numbers, you’ll be able to terminate all of them by sending the
kill -9 2551 2514 1963 1856 1771
As a substitute of looking for PIDs after which terminating the processes, you’ll be able to mix the above instructions into one:
kill -9 $(pidof firefox)
Reloading Processes Utilizing the
kill Command #
One other frequent use case for
kill is to ship the
HUP sign, which tells the processes to reload its settings.
For instance, to reload Nginx, you should ship a sign to the grasp course of. The method ID of the Nginx grasp course of could be discovered within the
nginx.pid file, which is often is situated within the
cat command to seek out the grasp PID:
When you discovered the grasp PID reload the Nginx settings by typing:
sudo kill -1 30251
The command above have to be run as root or consumer with sudo privileges.
kill command is used to ship a sign to processes. Essentially the most frequently-used sign is
-9, which terminates the given processes.
We hope the Kill Command in Linux help you. If you have any query regarding Kill Command in Linuxdrop a comment below and we will get back to you at the earliest.
We hope this post helped you to find out Kill Command in Linux . You may also want to see – Pgrep Command in Linux |