This hasn't happened to me yet but I am documenting this process just in case.

Let's say I can't remember my root password for my linux server. Every example of this scenerio that I can find says to first boot into single user mode. What if my server is currently running in multiuser mode and I have no sessions open as root. How exactly do I order an orderly shutdown without root access so that I can begin the password recovery process?


On most Linux systems from the console if you press CTRL-ALT-DEL the command shutdown -r now will be executed and cause a reboot of the system. If your init scripts are setup properly this should result in a safe restart. You could modify your inittab to make CTRL-ALT-DEL do whatever you want including switch into single user mode. Once your are rebooted you can use a livecd, boot to single user mode or whatever you like. You should test in advance if the root password is required to enter single user mode on your system. On some system it is not (Ubuntu/Debian when the root password is disabled) on others it is required.

If your system uses init then /etc/inittab

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

For systems with upstart then check the file /etc/event.d/control-alt-delete

# control-alt-delete - emergency keypress handling
# This task is run whenever the Control-Alt-Delete key combination is
# pressed.  Usually used to shut down the machine.

start on control-alt-delete

exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
| improve this answer | |
  • What if this system has been locked down to disable this feature from use by users? – Melvin Mar 23 '10 at 19:45
  • If you have locked out the root account, and you blocked use of control-alt-delete to reboot and taken other steps to lock down a system then there may be no possible way to safely reboot the system. If you are going to heavily lock down a system I would suggest you setup a secondary access method like key-based ssh, a second account with sudo privileges or something then do not use this secondary method for day-to-day operations. – Zoredache Mar 23 '10 at 19:50
  • 1
    If you don't want to setup a secondary method, you may want to make sure you have a good backup system in place, use a journaling filesystem. Then accept there may be a minor data loss and hit the power button. You could minimize this by simply removing any access to the system (pull the network cable) and wait a while and hope everything that needs to be committed to the disk gets committed. – Zoredache Mar 23 '10 at 19:54

Some ideas to avoid being bored with lost root passwords :

  • Don't use the root account, but your sudo-enabled user account.
  • Manage your servers with Puppet. Only change your root passwords with Puppet. That way, even if you lose your root password(s), you just have to modify the password(s) in the Puppet manifests, and wait till your servers fetch it.
  • Configure your servers to allow authentication based on LDAP.
| improve this answer | |

Depending on the OS, one quick way is to use SLAX, that is, use a live distribution to edit, either manually or with chroot, the /etc/passwd or /etc/shadow files ... or ... boot into single user mode and use the recovery procedure specific to the OS.

| improve this answer | |

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.