How to change the ‘root’ password from Grub.

How to change the ‘root’ password from Grub

Miguel Menéndez

How to remove root user password from Grub.

It will only work if the root (/) disk or partition is not encrypted.

In Grub, press e:

In Grub, press e.

I add, as the following images show, init=/bin/bash to the line linux /boot[...]:

I'm looking for the line 'linux /boot[...]'. And I add 'init=/bin/bash'.

Press Control + x to boot.

Now I have the system mounted in read-only mode:

I must remount the system in write mode.

I remount in write mode:

# mount -o remount rw /

Now I can edit the /etc/shadow file:

# nano /etc/shadow
Edit file '/etc/shadow'.

And I delete any characters between the first two colons on the line that starts with root:

I remove any character between the first two colons.

After restarting, I log in as root without a password. The first thing I will do is assign a new one:

# passwd

Comments

Found a bug? Do you think something could be improved? Feel free to let me know and I will be happy to take a look.