4

I am a newbie in Ubuntu, I have learned a command-

kill -1 -9 - send signal to process.

Plzz tell me what type of signal it is talking about and in the command what -1 -9 means?

1
  • Also have a look at man 7 signal which describes the signals and signal handling. – Thomas Jan 13 '18 at 13:54
15

I suspect the command you really learned of was

kill -9 -1

According to man kill, the format of the kill command is

kill [options] <pid> [...]

so -9 is an option and -1 is a PID or process identifier. As noted in the man page,

                                                               A PID of -1
   is special; it indicates all processes except the kill  process  itself
   and init.

while for an explanation of the signal values, you can either run man 7 signal or get a synopsis from the kill command itself with the -l option:

$ 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-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

So, as noted in the EXAMPLES section

EXAMPLES
       kill -9 -1
              Kill all processes you can kill.

The "you can" here is an oblique reference to privileges - in practice, ordinary users will not be able to kill processes that they do not own.


The actual command given in your question would attempt to send signal 1 (SIGHUP) to process -9 (which is not a valid PID) so will just return an error:

$ kill -1 -9
-bash: kill: (-9) - No such process
8
  • I think that the writer is wrong because I wrote the command as it is written on the cheat sheet. – coding_ninza Jan 13 '18 at 15:46
  • Is " -1 -9 " and " -9 -1 " in kill command both are same or not? – coding_ninza Jan 13 '18 at 15:55
  • 1
    @coding_ninza no they are not: the first one (attempts to) send signal 1 to a process whose PID is -9 (which is not a valid PID) whereas the second sends signal 9 to all process except itself and the init process, as explained in the manual page. – steeldriver Jan 13 '18 at 15:59
  • oh, ok I guess that command was written incorrectly on the cheat sheet. – coding_ninza Jan 13 '18 at 16:20
  • @steeldriver In the real question the -9 is a command-line argument and 9 is the PID try it. it works. -1 is not negative 1 but an argument 1 ( signal ). – Tobi Obadiah Jan 13 '18 at 20:06
-1
kill -1 -9

sends a SIGHUB to process with id 9

The first argument 1 is a numerical equivalent to a specific signal(SIGHUB) and the second 9 is a programPID.

SIGBU is describe as Hangup detected on controlling terminal or death of controlling process

On terminal kill -l list the various Linux signals and man 7 signal gives some descriptive overview of the various signals

3
  • Here what "1" and "9" stands for – coding_ninza Jan 13 '18 at 15:59
  • 1
    Hmm the would be kill -1 9 NOT kill -1 -9. I agree with steeldriver: it probably is kill -9 -1 since -1 is a special case. -9 is not a option, nor a valid process number since those are all positive except for -1 – Rinzwind Jan 13 '18 at 16:12
  • @coding_ninza Arguments passed in this way. The 1st represent signal type and the second PID – Tobi Obadiah Jan 13 '18 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.