2

I have sudo privileges on my home desktop running Fedora 22. I created a newuser with sudo useradd newuser and sudo passwd newuser. I then logged in as this newuser with su newuser, then switched back to myself with su dwayne.

I tried to delete the new user with userdel -r mewuser, but I got a message

userdel: user newuser is currently used by process 6415

p.s.: 6415 shows newuser is in a bash shell which makes sense since I logged in to the bash shell as newuser with su newuser. And here is where my question comes from, I tried sudo kill 6415 but it doesn't work nor does it give me any error message. Without an error you would think it all went as planned. I read the manpage for kill(2) but I did not find anything related to using sudo to kill a process. Is it possible to kill another users process with sudo or would I need to be logged in as root?

3

Yes, it is possible to kill a users process with kill. You will have to specify the -9 argument so it sends a SIGKILL signal.

Example: sudo kill -9 6415

Is it possible to kill another users process with sudo or would I need to be logged in as root?

Please note that when you are using sudo, you are in fact calling that command as root.

  • absolutely perfect. That works. thankyou. I will need to look into kill flags a little more. – Dwayne Nov 24 '15 at 20:57
  • @Dwayne, Glad to have helped! man kill will show and give an explanation of all the signals that can be sent with kill. – Peschke Nov 24 '15 at 20:59
1

Simply log out of the new user account (first logging out of the second dwayne session that you go to via su dwayne. That will get you back to your initial session, at which point you should be able to sudo userdel newuser without problems.

  • Yes that worked and I was able to delete the newuser, but I am still wondering about the functionality of killing another users process with sudo priveleges? – Dwayne Nov 24 '15 at 20:27
  • 1
    You can do so, yes - in this case, the process probably didn't respond to the kill signal because it "knew" it was active and shouldn't die. You can also try a kill -9 <pid> which is a more forceful "die NOW!" order than a simple kill <pid>. – John Nov 24 '15 at 20: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.