I try to kill a service as a other user. I login as a user "usernoroot" and kill a service of a root user "userroot"!

Therefore I have a killscript.sh in the folder of "usernoroot" like:

kill -9 $1

and make this script executable:

chown root:root /home/usernoroot/killscript.sh
chmod 755 /home/usernoroot/killscript.sh

Now I try to run ./killscript.sh <pid> but getting:

./killscript.sh: 2: kill: Operation not permitted

What can I do to run this script successfully?


I have installed sudo:

apt-get install sudo

add my user to group sudo

adduser usernoroot sudo

and add the script "killscript.sh to the sudoers

nano /etc/sudoers
usernoroot ALL=(ALL) NOPASSWD: /home/usernoroot/killscript.sh

Now I can execute ./killscript.sh 222 to quit the process with the id 222 without any PW.


First of all you are running the script as usernoroot that mean you don't have the right permeation to kill any process you don't own, so for killing any process on the system you can use sudo tool to run your script as root user:

sudo ./killscript.sh <pid>

There is another way to do that but I don't recommend it, it will make a serious security problem, and if it used in a wrong way it will make a big problems.

use a setUID on kill tool but you have to be root:

chmod 4755 /bin/kill

then any one can run the kill tool as a root user, I don't recommend this way

  • I'm on Debian without sudo?! – fteinz Feb 18 '17 at 9:26
  • @fteinz I edited my answer, you can install sudo on Debian – Wissam Roujoulah Feb 18 '17 at 9:44

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.