I am a newbie to Linux commands and was trying to delete a user on a CentOS 6 via an SSH connection on Putty, it was giving an error like "userdel: user is currently logged in", hence, i searched for a possible solution of this problem.

Googling on the above error i found a link Unable to remove user: "user is currently logged in" When i tried the solution given on this page and executed the "kill -9 -1" command after executed the "su - username" command the putty session was automatically closed and everything on that server just stopped working.

Any suggestions or any link which can help us out will be grateful to have as we are in a big danger because this is our main production server.

  • 3
    Congratulations, you killed init. Someone's going to have to powercycle that machine.
    – Shadur
    Jun 9 '15 at 5:03
  • @Shadur kill -9 -1 doesn't kill init. It's the only process for which the kernel implements such protection. So in principle the system can be configured such that after kill -9 -1 init will start the bare minimum of services again. If such configuration has not been done in advance, one shouldn't run kill -9 -1 as root (it is rarely a good idea anyway even if you have).
    – kasperd
    Jun 9 '15 at 5:56
  • kill -9 -1 kills all user process excluding init.
    – c4f4t0r
    Jun 9 '15 at 6:00

You shot yourself in the foot.

The only way that server is going to come back up is if someone powercycles it. Once it's back on, try to delete the user again.

The next time you get an error like this trying to delete a user, try to manually kill processes which owned by the user you want to delete (ps aux|grep <username> or `pkill -u ) and try again.

  • Thanks a lot you saved me. And thank god Digital Ocean have a console access via their dashboard to which we can reboot a system. @Shadur thanks for your immediate response as you got me the idea of rebooting the system. Jun 9 '15 at 5:19
  • 2
    After analyzing the "/etc/passwd" if found an entry of the user which i want to delete as follows user1:x:0:0::/home/user1:/bin/bash which i think has privileges as a root user and therefore, deleting that user even after executing su - user1 command caused the pid "1" to be killed for the root user as well. Please correct me if m going in a wrong direction. Jun 9 '15 at 6:43
  • @user1321244 Looks like somebody messed things up pretty badly when creating that user.
    – kasperd
    Jun 9 '15 at 6:47
  • The "good" (relatively speaking) news is that you can just delete that user's entries from /etc/passwd and /etc/shadow and clear its home directory and you'll be set... But I recommend taking a blunt object when you discuss this particular security feature with the admin that set that system up.
    – Shadur
    Jun 9 '15 at 18:21

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.