If you accidentally forgot your root or user password of Linux OS, you can reset it from the terminal/ safe mode. This article will show you how to reset root or user password of Linux OS.

Side effect & Note: Previous users login.keyring will not work. Hence, you will loss all previously saved wifi/network drives as well as Google Chrome profile settings (until you remember the old password and unlock it).

Reset root password of Linux OS

To reset root password of Linux OS, you need to boot your system in recovery mode. To do so, you need to restart your system and press e key to edit the boot options. Then, you need to add single and init=/bin/bash to the end of the line starting with linux and press Ctrl+X to boot your system in recovery mode.

Once your system is booted in recovery mode, you need to mount the root file system by running the following command:

mount -o remount,rw /

Then, you need to change the root password by running the following command:

passwd

Finally, you need to reboot your system by running the following command:

reboot

Reset user password of Linux OS (From terminal)

Open a terminal and run the following command:

sudo passwd username