Lost Linux root password – Recovery mode and init=/bin/bash fail

Albeit asked:

I lost/forgot the root password to a server sitting beside me and am trying to reset it. I would rather not have to wipe and re-install or use a Live CD (server is running Ubuntu Server 12.04). What I’ve tried so far…

1) Boot into “Recovery mode” from Grub2 boot menu then drop into root shell prompt. I am prompted to “Give root password for maintenance”. No-go.

2) Change the boot parameters for the main boot option to include “rw” and “init=/bin/bash”. When I then boot with Ctrl-X, the screen goes black, and nothing happens (I’ve waited five minutes). init=/bin/sh and init=/bin/static-sh both do the same thing, while init=/sbin/init boots as normal.

Is there anything else I can try to reset the root password? Thank you!

My answer:

If you’re already rebooting, just boot into the Live CD, chroot into the server’s root filesystem, and run passwd. Problem solved.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.