16

I forgot my root password and am attempting to change it by booting into single-user mode, however when booting I get this screen:

enter image description here

Then I press "e" to edit the boot configuration and I get this screen:

enter image description here

However, in the tutorial I'm following it says I should navigate to the line that starts with "kernel", but as you can see, I dont have this line. So I tried changing "quiet" to "single" on the line that starts with "linux /boot/vmlinuz...." but this doesn't boots the system into single-user mode.

What line am I supposed to edit in order for this to work?

4 Answers 4

19

One method:

  1. Append init=/bin/bash to the end of the grub line which begins with linux (and ends with quiet).

  2. Reset your password and reboot normally.

  3. Don't forget it again.

  4. Consider installing sudo.


Another method:

  1. Since this is apparently a virtual machine, you can mount its disk on another (working) virtual machine and manually remove the password from the /etc/shadow file. Or use kpartx to work with the virtual machine image file from the host or from another machine.
3
  • Now it shows me "root@(none)#" though and it doesn't know any commands, how do I fix that?
    – xorinzor
    Feb 24, 2013 at 23:18
  • 2
    You probably don't have a PATH. Try calling /usr/bin/passwd (or anything else) directly. Or just look around and see what you have available to you. Feb 24, 2013 at 23:19
  • 2
    using /bin/bash as init won't call any of the startup scripts to mount partitions, etc. either so if you have /usr in a separate partition you'll need to mount it by hand. Also know that you won't get the shutdown scripts either, when bash exits the kernel will immediately halt. Be sure to sync the drives first or changes may not be written.
    – DerfK
    Feb 25, 2013 at 0:12
24

DEBIAN / UBUNTU root PASSWORD RECOVERY

  1. First screen - grub - press e
  2. Modify kernel line: add single between ro quiet and at the end of this line add init=/bin/bash
  3. Press F10
  4. When the prompt is root@(none):/# you have to remount the / partition to have read-write access: mount / -rw -o remount
  5. Now you are ready to modify the root password: type passwd and change it!

Good luck

P.S: try to look at the /etc/shadow file to find other users...

2
  • This was the right answer for me, with the mount command. Thanks.
    – Thibault
    Jan 26, 2016 at 13:19
  • You may also want to, instead of remounting / as rw, just change the ro in the kernel line to just read rw.
    – Eugéne
    Sep 11, 2023 at 12:12
1

Your tutorial refers to Grub (legacy Grub). This is Grub2. The line beginning with linux would be the kernel line in Grub.

1
  • I don't have a tutorial written anywhere, this was an old question of mine
    – xorinzor
    Jul 21, 2016 at 19:28
-1

wooo, just choose the recovery mode dude, you'll be switch to a BusyBox without any kind of password (normally).

6
  • Just tried it, also asks for a login after booting, during the boot I get the same maintenance question asking me for the root password or to press ctrl+D to continue
    – xorinzor
    Feb 24, 2013 at 23:11
  • did you press Ctrl+D ? I already had such reaction on some linux tweaked box, and a Ctrl+D did the trick.
    – Dr I
    Feb 24, 2013 at 23:14
  • yes I did, but then it just resumes like a normal boot and asks for the login
    – xorinzor
    Feb 24, 2013 at 23:15
  • 1
    @DrI Debian's default is to require the root password for single user mode.
    – DerfK
    Feb 25, 2013 at 0:14
  • Hum... are you sure?? I just installed a fresh Inet 6.0.6 version using default values for the setup and my single mode is NOT requiring any password.
    – Dr I
    Feb 25, 2013 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .