Lost Linux root password - Recovery mode and init=/bin/bash fail
Solution 1
If you're already rebooting, just boot into the Live CD, chroot into the server's root filesystem, and run passwd
. Problem solved.
Solution 2
I just tried on a near-blank Ubuntu server 12.04 in Virtualbox. Holding SHIFT down while booting, choosing the first entry, pressin "e" to edit, I replace
ro quiet
with
rw nosplash boot=/bin/bash
and it boots up without problems into a bash-shell. Perhaps the graphic-cards is making you trouble, thus the nosplash
.
Related videos on Youtube
Albeit
Updated on September 18, 2022Comments
-
Albeit over 1 year
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!
-
Zoredache over 11 yearsIf you would have left Ubuntu with the standard configuration, then root would have a disabled password, and you would have gotten a menu you when you went into recovery mode. Did you also forget the password for the first account that had sudo access?
-
mdpc over 11 yearsHave you considered using sudo that way you would not need to use the root password all the time?
-
Penge58 almost 3 yearsThank you all for helping me. I ended up with a clean debian re-installation. I now have to reinstall apache and other software from scratch again.
-
djdomi almost 3 yearsDoes this answer your question? Lost Root and other user passwords
-
djdomi almost 3 yearsBy the way booting a live boot medium would fix your issue, since you can edit then the /etc/password and remoe the password marker to get a password less root this is how i do
-
-
alchemy over 2 yearsOMG, its taken me hours to find how to interact with a VM during boot. I'm using an Ubuntu cloud image that uses cloud-init which changes passwords. I tried inserting kernel args with
vboxmanage setextradata
but it doenst allowinit=/bin/bash
. Thank you for this! -
alchemy over 2 yearsWow, I forgot that was a grub thing. I think I only used that once ages ago because I use AIOBOOT which allows editing grub boot commands.