Home Ubuntu How to reset Administrator/Root password on Ubuntu

How to reset Administrator/Root password on Ubuntu

by Kiran Kumar
Published: Last Updated on
Ubuntu Password Reset

By default, Ubuntu doesn’t have a root password, and the root account is locked. The user account created while installing Ubuntu should be set up as an administrator with sudo access. However, this does not infer that you are a root user.

The lack of a root password is a design choice. From the “root shell prompt,” you can execute some particular root-related actions using the “advanced options for Ubuntu” in the boot menu. This is why you can use this method to reset the Ubuntu password. To make your system more secure, you can encrypt the disk or set up a password for the root user.

Ubuntu has a key ring feature that is used to keep passwords locked and safe. When resetting the forgotten password, the keyring remains unlocked, and an error message will appear, prompting you to enter a password to unlock your login keyring. Open the Passwords and Keys application, and here, delete the login passwords. When you try to use Google Chrome in Ubuntu, it will ask you to create a new keyring. Use the new login password as the keyring password.

Ubuntu Security

By default, Ubuntu aspires to be secure. User applications have limited privileges and are unable to harm the operating system or other users’ files. The sudo utility grants temporary administrative powers for improved security, allowing the root account to remain locked and preventing untrained users from accidentally making system changes or exploiting security weaknesses.

To avoid hacking, most network ports are closed by default. End-users who install network servers can limit access with a built-in firewall. It can be configured using a GUI (GUI for Uncomplicated Firewall). Ubuntu hardens its program by compiling it with GCC features like PIE and buffer overflow protection. Ubuntu also supports full disk encryption as well as home and private directories encryption. These extra features considerably improve security at the cost of 0.01 percent performance in 64-bit.

It’s natural to forget the password if you haven’t used Ubuntu in a long time. The exciting news is that you won’t be required to reinstall your operating system as a result of it. Ubuntu passwords are simple to retrieve.

The approach described here can be used to reset an Ubuntu password in Virtual machines, dual boot configuration, or single install environments. All you need is a little patience and the ability to run a few commands. You’ll be able to reset the root password in a matter of minutes by following these steps;

Reset root login password in Ubuntu

1. Boot into recovery mode

Turn on the computer, then go to the grub menu. If the boot menu does not appear automatically, hold down the shift key or hit the Esc key until the boot menu appears.

Hold down the shift key when the Oracle or VMware logo displays if you’re using Oracle Virtual Box or VMware. Next, select “Advanced Options for Ubuntu” from the grub menu. Next, you will see the option that will take you to recovery mode. On clicking the option, it will bring you to a black screen with several lines of output being displayed in a flash. Wait for a few seconds on this screen.

Use UP/DOWN arrow keys to navigate and select ‘Advanced options for Ubuntu’.

Grub - Ubuntu

Grub – Ubuntu

Select the second item in the list ‘Ubuntu, with Linux 4.2.0-30-generic (recovery mode)’. The Linux version, in your case, maybe different depending on your Ubuntu version.

Launch Ubuntu Recovery Mode

Launch Ubuntu Recovery Mode

2. Drop to a root shell prompt

Once in Recovery mode (also termed Safe mode), use arrow keys to navigate and select ‘root’, and hit enter.

You should now see a root prompt at the bottom of the same screen.

root@ubuntu:~#

3. Remount the root with write access

You will be required to have write access to the root partition since, by default, it has read-only access. To have write access, use the following command to remount it with write access:

Currently, the Ubuntu file system will be read-only. You must remount it with write permissions:

mount -rw -o remount /
Ubuntu Recovery Mode

Ubuntu Recovery Mode

4. Reset Username or password

You will be given root access. Use the command below to list all the users available.

ls /home

Based on this command, choose the Username for which you want to reset. Now use the command below to reset the password for the selected Username:

passwd username

In our example, we shall use Unix ‘passwd’ command to reset the password for an account “kiran”.

root@ubuntu:~# passwd kiran
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Ubuntu Password Reset Success

Ubuntu Password Reset Success

You will be prompted to add a new password. Enter the new password twice. After confirming the password, you will have successfully reset the password. You can now exit the root shell prompt. After leaving the root shell prompt, you will be back at the recovery mode menu, where you will select the normal boot option.

A warning about graphics mode compatibility will appear. It would be best not to worry about this since a complete reboot will fix all issues. You shall now be able to log in with the new password.

Possible troubleshooting:

When you enter the new password, you might be prompted with an Authentication token manipulation error that looks like the one below:

passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

This error appears because the file system is mounted with reading access only. Change the access and remount the file system using the command below:

sudo mount -rw -o remount /
remount root with write access

remount root with write access

Now try resetting the password again.

Alternative steps of resetting Ubuntu password

Try these steps if, for some reason, you are unable to drop to the root shell and change the password.

1. Reboot your computer, then hold shift to bring up the grub screen (if it does not appear automatically). Next, click E at the grub prompt to edit the grub screen.

2. On the screen, find a line that starts with “Linux.” Change the ro to rw and add init=/bin/bash at the end of that line

3. Click ctrl-x to save your changes and boot. You will be booting into the Linux kernel with read and write permissions. Instead of going to a graphical user interface, you will use the bash shell (your system will boot up to a password-less root shell).

4. Type the passwd command with your Username in the root shell prompt to reset your password on Ubuntu. If you don’t know the Username, use the ls /home command to find out, as we did earlier on.

Create a new password. Exit the terminal once you’ve set the new password. Type reboot or use the shutdown command on the terminal.

shutdown –r now

Your password should be changed by now.

Conclusion

Security is one of the key advantages of Linux over Windows. If resetting Ubuntu passwords is this easy, you may think that this is a security risk. The major security danger is if someone hacks into your account via the internet from a remote location. That is not the case here. The data on your computer is already at risk if someone has physical access to it. Anyone can “steal” your data via a live USB without even visiting your installed operating system unless the entire disk is encrypted.

We hope the article educated you about changing and setting a root password in Ubuntu. Sometimes you might fall into errors, but it is normal. To evade being a victim of errors, ensure you stick to the article and copy and paste the given code than manually typing them. If you find the article helpful, give a thumbs up via the comments section. Thanks for reading.

You may also like

1 comment

Juergs July 3, 2018 - 2:56 AM

Thank you, Kiran, for this so helpful article! After an update from ubuntu 12 to 14.04 LTS ubuntu wouldn’t accept my original password any more, so I was in a bad fix.
BUT: Although having followed your instructions (and finding everything as described), I couldn’t go on from the point where it’s asking me for the new UNIX password. NO KEYBOARD STROKE seems to work. If I hit return, it re-asks the new password.
But in the end I always receive the message that changing the password didn’t work (I’m using German language system, so I didn’t give the exact wording – but the meaning).
How can I get around this, Kiran? It would be nice if you could give me a clue. Thank you!

Reply

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.