Pages

Wednesday, June 28, 2017

A Guide to Kill, Pkill and Killall Commands to Terminate a Process in Linux

Linux Operating System comes with Kill command to terminate a process. The command makes it possible to continue running the server without the need of reboot after a major change/update. Here comes the great power of Linux and this is one of the reasons, why Linux is running on 90% of servers, on the planet.
Linux Kill Command
Kill, Pkill and Killall Commands Examples
Kill command send a signal, a specified signal to be more perfect to a process. The kill command can be executed in a number of ways, directly or from a shell script.

Using kill command from /usr/bin provide you some extra feature to kill a process by process name using pkill. The common syntax for kill command is:
# kill [signal or option] PID(s)
For a kill command a Signal Name could be:
Signal Name  Signal Value   Behaviour
SIGHUP         1    Hangup
SIGKILL         9    Kill Signal
SIGTERM         15   Terminate
Clearly from the behaviour above SIGTERM is the default and safest way to kill a process. SIGHUP is less secure way of killing a process as SIGTERMSIGKILL is the most unsafe way among the above three, to kill a process which terminates a process without saving.
In order to kill a process, we need to know the Process ID of a process. A Process is an instance of a program. Every-time a program starts, automatically an unique PID is generated for that process. Every Process in Linux, have a pid. The first process that starts when Linux System is booted is – init process, hence it is assigned a value of ‘1‘ in most of the cases.
Init is the master process and can not be killed this way, which insures that the master process don’t gets killed accidentally. Init decides and allows itself to be killed, where kill is merely a request for a shutdown.
To know all the processes and correspondingly their assigned pid, run.

      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBRdo
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment