0

In Linux, you can do the following:

kill 1 (or kill %1)

Which means "close the processes in job number 1".

And you can do the following:

kill 1234

Which means "send the SIGTERM signal to the process with PID 1234".

Are these two kill commands the same command, or are they two different commands?

4

I’m not sure you can do kill 1 (or rather, you can try, but you won’t be allowed to, unless your root, and then you’re in for a surprise). 1 here always refers to the process with id 1, which is usually init (or some variant thereof).

To actually answer your question, if you’re in a shell which supports job control, kill will be a shell built-in, handling both cases (managing jobs and processes). See for example Bash’s kill command.

If you’re in a shell which doesn’t support job control (are there any?), kill will be a binary in the system, typically /bin/kill; see for exampleutil-linux’s kill command. Even in a shell with a built-in kill command, you can access this one for example by specifying its full path. This kill command is also accessible without a shell (for use from another program).

See also POSIX’s definition of kill, which covers both cases (but doesn’t specify what is implemented where).

  • (Yes, the Thompson shell.) – JdeBP Nov 24 '17 at 16:44
  • Hah @JdeBP, perhaps I should have said “in widespread use”! – Stephen Kitt Nov 24 '17 at 16:45

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.