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.
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’.
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.
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.
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 /
4. Reset Username or password
You will be given root access. Use the command below to list all the users available.
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:
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
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.
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 /
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.
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.