Linux tricks – how to kill a process

1. A list of common Term signals :
SIGHUP (1) – Hangup detected on controlling terminal or death of controlling process. Use SIGHUP to reload configuration files and open/close log files.
SIGKILL (9) – Kill signal. Use SIGKILL as a last resort to kill process. This will not save data or cleaning kill the process.
SIGTERM (15) – Termination signal. This is the default and safest way to kill process.

2. Kill command syntax :
kill [signal] PID
kill -15 PID
kill -9 PID
kill -SIGTERM PID
kill [options] -SIGTERM PID
Or a command for killing all things connected to a process or service :
# killall Process-Name-Here

3. Rules for permissions to kill a process :
You can kill all your own process.
Only root user can kill system level process.
Only root user can kill process started by other users.

4. Which is all well and good, but how to find process PID.
If you know process name :
# pidof lighttpd
Or
# ps -axf | grep lighttpd
If you know which file/folder your process is using :
# lsof /home/velda/Desktop/Turgenjev

Good link1 and link2.

This entry was posted in Linux and tagged . Bookmark the permalink.

Comments are closed.