Strange behavior from kill command

I am getting some strange behaviour from the kill command. When I run the which command it says it points to /usr/bin/kill. When I look at my PATH I have /usr/bin in it. So why does running kill or /usr/bin/kill produce different outputs?

ghost ~
$ which kill
/usr/bin/kill

ghost ~
$ kill
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

ghost ~
$ /usr/bin/kill
Usage: kill [-f] [-signal] [-s signal] pid1 [pid2 ...]
       kill -l [signal]

Send signals to processes

 -f, --force     force, using win32 interface if necessary
 -l, --list      print a list of signal names
 -s, --signal    send signal (use kill --list for a list)
 -h, --help      output usage information and exit
 -V, --version   output version information and exit

Please post the output of the command (in code tags of course):

env
$ type -a kill
kill is a shell builtin
kill is /usr/bin/kill
kill is /bin/kill
2 Likes

I'm guessing which is an external command in your environment. As such it doesn't take into consideration builtin commands (which is why it is much better to use type on bash, ksh and dash). The reason for the difference in output from the two commands is they are literally two different commands. One is your shell's builtin command and the other is the system command.

Andrew

1 Like

which is a builtin in tcsh and zsh .
Many OS also have a /usr/bin/which command.
All Bourne-type shells have the type builtin, but its options and output format differ.

This is correct. Thank you.