What is the Kill command?
The kill <number> PID, the command enables you to terminate tasks or processes by specifying a signal value for <number> and a process id for PID.
The value of <number> can be 1, 2, 3, 6, 9, 14, or 15.
For example, both of the following commands will terminate a process with a “hangup” signal: kill -1 2345
kill -s HUP 2345
You can terminate a process whose PID is 2345 with kill -3 2345 and kill -9 2345, which are signals QUIT and KILL, respectively.
However, the signal
QUITcan be “caught” via the “trap” command,whereas the signal
KILLforces a process to terminate immediately(i.e., as soon as the operating system can execute this command).
Moreover, the signal
KILLcannot be caught via the “trap” commandand it cannot be ignored.
Note: Only superusers can send a signal to another user’s processes.
Perform an online search for more details regarding the kill command, or check the man page with this command: man kill
Terminating Multiple Processes
The kill <number> PID the command enables you to terminate multiple processes by specifying a list of processes, an example of which is shown here:
kill -1 5000 5010 5135 68238
Another scenario involves multiple child processes that have the same parent process. For example, when you launch multiple browser sessions in Chrome or Firefox, each browser session will have an associated PID.
There are two ways to terminate all the child processes and the parent process. One technique is to terminate the parent process that appears in the monitor utility.
However, if you need to terminate these processes from the command line, you can invoke the following command:
ps -ef |grep -i firefox | awk '{print $2}' | xargs kill -9






