kill Command in Linux

Back

Sometimes, it's not enough to re-prioritize a process. Some processes can just overwhelm a system. With some other operating systems, such situations requires a reboot. Linux is different. In most cases, you can stop such difficult processes with the kill and killall commands. In many cases, you can kill process directly from the top task browser.

If there's a situation where a process is taking up a lot of memory or CPU, you could apply the kill command directly to a PID number. For example, the following command is equivalent to steps just described in the top task browser :

# kill 2971

The kill command can be run by the owner of a process from his account. Thus, user michael could run the kill 2971 command from his regular account, as he has administrative privileges over processes associated with his user name.

 The kill command can send a wide variety of signals to different process. For a full list, run the kill -l command. Before the advent of scripts in the /etc/init.d directory, the kill -l command was used to send a restart signal to service daemons. For example if the PID number of the process associated with the vsFTP server is 2059, the following command is functionally equivalent to the /etc/init.d/vsftpd restart command.

# kill -1 2059

With out the -l  switch ,the kill command , under normal circumstances, would stop the given process. In this case, it would stop the vsFTP server. But sometimes, processes get stuck in loops. In some such cases, the kill command does not work by itself. The process continues running . In that case you can try two things.

First you could try the kill -9 command, which attempts to stop a process "uncleanly". If it is successful, other related processes running under the same name. For example the Apache Web Server starts several processes that run simultaneously. It's at best inefficient to kill just one process; the following command would kill all currently running server processes, assuming no other issues.

# killall httpd