How To Change The Root Password, When Root Password Is Unknown

How To Change Kernel Parameters

Instructions from Milosz Galazka

In case the Recovery mode menu entry is not available, you need to perform five simple steps in order to modify kernel parameters list.

  1. Turn on computer.
  2. Access GRUB menu.
  3. Edit existing menu entry (use e key).
  4. Add single keyword (alternatively you can use -s or S ) to the Linux kernel parameters list.
  5. Press CTRL-X or F10 while still in edit mode to continue boot process.

How To Reset The Root Password

Instructions from TecMint

Now check the status of root partition by running following command on the single user mode.

# mount | grep root

Check Root Mount Status> > You may notice that root partition is reported to be 'ro' (Read Only). We need to have read-write permission on root partition to change the root password.

# mount -o remount,rw /

Also cross check, if the root partition is mounted with read-write permission mode.

# mount | grep root

Set Permissions on Root Partition> Now you can change the root password by typing the passwd command. But that is not done. We need to relabel SELinux context. If we skip relabeling the whole SELinux context we would be able to login using using password.

# passwd root
[Enter New Password]
[Re-enter New Password]

# touch /.autorelabel Reset root Password> Reboot and login again to root account and see if everything works ok or not?

# exec /sbin/init

Fixing Emergency Mode Error

Instructions from Molesbite Hacks

Type systemctl

You'll get a list of logs, scroll till you find the error highlighted in red.

Type fsck /dev/mapper/fedora-root

Hit Y (yes)

When I initially ran fsck /dev/mapper/fedora-root, I got a error that wouldn't allow me to commit the changes

I decided to run systemctl and look for the red error

In my case, the error was in /dev/mapper/fedora-root

I modified the directory to be /dev/mapper/fedora-home, matching the one listed by systemctl

Explanation Behind All Steps

Why We Change Kernel Parameters

We changed the kernel parameters so that we avoid regular boot, as it would be stuck in emergency boot.

Why We Unmount And Remount The Root Partition To Reset The Root Password

As explained in the TecMint article, we unmount and remount (with mount -o remount,rw /) the root partition so that we have read-write access to modify the root's password.

Why We Use systemctl Instead of journalctl

journalctl shows logs for everything including boots. If you have multiple boots, you may generate multiple logs. Using systemctl focuses on only the system processes, so the list is smaller to scrub through