Bootstrap FreeKB - Linux Commands - kill (end a process)
Linux Commands - kill (end a process)

Updated:   |  Linux Commands articles

The kill command can be used to end a process. For example, let's say the gedit program is using process ID (PID) 16674. The kill command followed by 16674 will end the gedit process.

[john.doe@server1 ~]# kill 16674

 

The kill command can use the PID or Job ID number of the process to end. However, the kill command cannot accept the name of the process. For example, kill gedit cannot be used to end the gedit process. Instead, the killall command can be used to end a process using the process name.

 


SIGNALS

The kill command can use different signals. A signals represents how a process should be ended. For example, the terminate signal is less aggresive than the quit signal. The kill command with the -l flag can be used to list the signals.

~]$ kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX

 

When a certain signal is not specified, the terminate signal is used. 

The kill command followed by the signal name or signal number can be used to end a process with a particular signal. In this example, the hangup signal is used.

[john.doe@server1 ~]# kill -1 16674

 

In this example, the quit signal is used.

[john.doe@server1 ~]# kill -sigquit 16674

 


WORKING EXAMPLE

Let's take an example where gedit is opened in the foreground, and then Ctrl + Z is issued in the Terminal to stop gedit. Gedit remains open, and the kill command with the default terminate signal fails to end gedit.

 

In this scenario, using a different kill signal should end gedit. The kill signal (9) is able to end gedit.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 1ac62c in the box below so that we can be sure you are a human.