0

I have Debian Stretch..

I thought that a regular user could kill root process as root. I was using the command /bin/kill 10733 as the user. There wasn't any error message. Then, I typed out the similar command (without /bin/ prefix) and the error message got displayed.

Here, is the command history

deployer@deployer:~/blog$ kill 10733
-bash: kill: (10733) - Operation not permitted
deployer@deployer:~/blog$ /bin/kill 10733
deployer@deployer:~/blog$ ps aux|grep 10733
root     10733  0.0  0.6  92360  6404 ?        Ss   19:19   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
deployer 10891  0.0  0.2  12732  2236 pts/0    S+   20:10   0:00 grep 10733
deployer@deployer:~/blog$ sudo kill 10733
deployer@deployer:~/blog$ ps aux|grep 10733
deployer 10900  0.0  0.2  12732  2232 pts/0    S+   20:10   0:00 grep 10733
deployer@deployer:~/blog$ 

In fact, I would prefer both the prefix and the message. How to get it? And why is it so?

4

In your example, the kill command is a shell internal (definitely in bash) and it allows for extensions such as %1 to be used to refer to background processes.

On the other hand, /bin/kill is an external command and doesn't have these extensions. Since it's a different program it acts differently. A failed /bin/kill may be silent, but sets $? (exit code) to indicate a failure.

When you run sudo kill you are implicitly running sudo /bin/kill.

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.