Reset Root Password Linux Mint

Reset Root Password Linux Mint

we’ve all been there. You need root and nobody remembers the password. If you have console access to the machine, you can boot straight into a root shell from GRUB and set a new one. Reboot Linux Mint.

Prerequisites

  • Physical or virtual console access to the machine (this does not work over SSH).
  • A root file system that is not encrypted, or the passphrase to unlock it.

Step 1: open the GRUB menu

Hold the Shift Key (that will get you into the grub menu)

On machines that boot with UEFI, tapping Esc right after the firmware screen usually does the same.

GNU GRUB 2.00 edit screen with the linux line ending in quiet splash $vt_handoff

Step 2: edit the boot entry

press the “e” key to get into boot params

GRUB boot entry opened for editing after pressing e

replace the text where the arrow is ($vt_handoff) to init=/bin/bash

Red arrow at $vt_handoff on the GRUB linux line, the text to replace with init=/bin/bash

init=/bin/bash tells the kernel to start a bash shell as the very first process instead of the normal init system, so you get a root shell without a login prompt. The change only applies to this one boot.

Step 3: boot into the shell

Now Press F10 to continue the boot

Root shell prompt (none) / # after booting with init=/bin/bash

The prompt shows (none) because the hostname has not been set yet. A message like bash: cannot set terminal process group is normal here.

Step 4: remount the root file system read-write

from here we need to mount our root partition

mount -o remount,rw / typed at the (none) root shell

The root file system is mounted read-only at this stage, so the password change could not be saved. Remount it read-write:

mount -o remount,rw /
mount -o remount,rw / and passwd root, password updated successfully

Step 5: set the new password

issue the passwd root command

passwd root

Enter new password

passwd root updated successfully followed by the sync command

issue the sync command so that changes are synced to OS, and reboot

sync
reboot -f

sync flushes the change to disk. The -f is needed because there is no init system running to do a normal reboot.

Step 6: verify

login, and make sure you can SU to root with success.

Linux Mint terminal, su root accepted with the new password

That’s it!

Troubleshooting

  • passwd: Authentication token manipulation error: the root file system is still read-only; run the remount command again.
  • No GRUB menu appears: hold Shift as soon as the firmware screen disappears, or tap Esc on UEFI systems.
  • Keyboard layout: the shell uses a US layout, which matters if your password has symbols.

Notes

On Linux Mint and Ubuntu the root account is locked by default and admin work is done with sudo. If you just forgot your own user’s password, run passwd yourusername at the same shell instead. Anyone with console access can do this, so protect GRUB with a password on machines where that matters, and pick a good password with Choosing a Smart Root Password. The same steps work on current Linux Mint releases.

If you are interested in a Linux-Based solution, visit www.zwiegnet.com/go to get started today

Related guides: Install Ksplice on Linux Mint | Choosing a Smart Root Password

Leave a Reply

Your email address will not be published. Required fields are marked *