0

I want to run pkill like below.

sudo pkill -u 11002

I cannot give sudo password multiple times, so I want to run pkill without sudo user. For this i copied pkill to home as named bkill, and then i have run the following command.

sudo setcap "cap_kill+epi" /home/rajesh/bkill

This will give kill capabilities to this binary. But whenever i run i am getting following message.

 /home/rajesh/bkill  -u 11002
result: 31270

I check running processes of that user using below command.

ps -u 11002

PID TTY          TIME CMD
340 pts/26   00:00:00 ncserver

This is showing process pid 340 is still running. I assumed cap_kill is not working.

So I tried a different approach. I have given sudo access using below commands.

sudo chown root /home/rajesh/bkill
sudo chmod u+s /home/rajesh/bkill

Even this way also not working.

Can anybody help me to resolve this??

  • The process in question may be trapping SIGTERM. Try SIGKILL (pkill -KILL or pkill -9). – muru Sep 4 '14 at 15:03
  • I tried those all signals. nothing is working. Anyhow thanks for your reply. – Rajesh Barri Sep 4 '14 at 17:43
  • It's possible that process is in uninterruptible sleep, which is why signals aren't affecting it. – muru Sep 4 '14 at 18:05
2

Why don't you just give yourself permission to run pkill without a password:

sudo visudo

add

rajesh ALL = NOPASSWD: /usr/bin/pkill

You'll still need to sudo pkill, but you won't have to type a password.

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.