1. Home
  2. Linux
  3. Ubuntu reset root password or user password guide

Ubuntu: reset root password or user password [Guide]

Are you having trouble logging into your Ubuntu PC with the root password or your user password? Want to learn how to reset these passwords? We can help! Follow along and learn how to reset your root password or user password on Ubuntu!

Reset root password – Access Ubuntu recovery mode

The only way to safely reset a forgotten root password on Ubuntu is by accessing Ubuntu recovery mode. Ubuntu recovery mode is an option available to all Ubuntu users via the Grub bootloader prompt. Here’s how to access it.

First, reboot your Ubuntu Linux PC if it is turned on. After restarting it, you’ll see the Grub bootloader screen that always appears when you turn on your PC to log into Ubuntu.

Note: you may need to hold down the Shift key (or Esc key on UEFI) as Ubuntu starts up if you do not see the Grub bootloader.

Look through the boot menu for the “Advanced options for Ubuntu” menu option. Then, using the Down Arrow key on the keyboard, select “Advanced options for Ubuntu.” Press the Enter key on the keyboard to access it.

Inside of the “Advanced options for Ubuntu” menu, there are several choices to choose from. Locate the option that has “(recovery mode)” at the end of it. Recovery mode in Ubuntu can only be accessed through this option.

After locating an option in the “Advanced options for Ubuntu” menu, press the Enter key. By selecting Enter, the Ubuntu recovery area should boot up. However, be patient, as recovery mode may take a bit of time to load up fully.

Access recovery shell prompt

With Ubuntu recovery mode loaded up, you will see the “recovery menu.” In this menu, use the Down Arrow key to select the “root” option. Then, press Enter to load it up.

After selecting the “root” option in the menu, the recovery menu will show a message. This message says, “Press Enter for maintenance (or press Control-D to continue). 

Press the Enter key on the keyboard. By pressing this button, Ubuntu will attempt to load up the shell prompt as root. After loading up the shell prompt, it will attempt to log into root without a password.

To confirm you are logged into root, you can run the whoami command.

Reset root password – Recover password with recovery shell

If you’ve forgotten your root password on your Ubuntu PC, it can be rest quickly in the recovery shell you’ve just booted up. The password can easily be reset because recovery mode will automatically drop you in a root shell without the need to enter a password.

To reset the root password in recovery mode, you will need to use the passwd command. Using the command below, reset the root password. 

passwd

After entering the passwd command above in the recovery shell, Ubuntu will ask you to enter a new password. Be sure that you enter something memorable for your new root password during this process, but not so complicated that you forget again.

When the password is reset, reboot Ubuntu and log in as usual!

Reset user password

If you’re on Ubuntu and you need to reset a user password rather than the root password, things work a little differently. First, reboot into the Grub menu. Once in the Grub menu, find the “Advanced options for Ubuntu” menu and press the Enter key to access its sub-menu.

Inside of the advanced menu, select the option that says “(recovery mode)” and press Enter. Then, in the Recovery Menu, select the “root” option to load the shell.

Inside of the shell, you will be dropped down to the root account. After accessing the root account, you will be able to change a user account’s password using the passwd command.

For example, to change the “derrik” user’s password, you’d execute the following command.

passwd derrik

Specify the user account alongside the password account, and your Ubuntu system will change the password.

passwd user-account

Change password without live disk

If you need to change a forgotten user’s password on Ubuntu and you do not have access to a live USB installer, here’s what to do. Be sure you have access to the root account’s password, as it is needed for this method to work successfully.

First, press Ctrl + Alt + F3 on the keyboard. By pressing this keyboard combination, you are opening up a TTY emergency console window.

Inside the emergency console window, write “root” as the username in the “login” area. Then, enter your Ubuntu PC’s root password.

After using the root password, execute the passwd command to reset the user account’s password.

passwd user-account

With the password reset, press Ctrl + Alt + F2 to exit TTY mode. Once out of TTY mode, you should log into the user account with the new password at the login screen.