
In this tutorial you will learn how to set or change the root password on Ubuntu Linux.
In all Linux systems, root user is a special user account (superuser). Using root user you can perform all the command and get access to any resource on the system without any restrictions.
By default, the root user account disabled in Ubuntu Linux for security reasons. As a result, you can not login using root user or use a command such as su -
to become a SuperUser.
Change root password in Ubuntu
In Ubuntu Linux root user account is exist just it has been disabled for security reasons. Logging in as root is not possible because no password has been set for the root account. To enable the root account you need to set a password for root user. You need to use the passwd
command to change or set the password for user accounts on Ubuntu Linux.
Execute the below command as a sudo user to change password on Ubuntu Linux:
sudo passwd root
It will prompt you to enter and confirm the new root password.
You should make sure your password is strong and unique. A strong password includes at least 16 characters, at least one uppercase letter, one lowercase letter, one number, and one special character. The password is not shown on the screen when you type it.
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Alright, it’s done! The root password has been changed.
You can now log in to your Ubuntu system as root using the new password.
Understanding passwd command option
- -d OR –delete : Delete a user’s password (make it empty for root user). This is a quick way to disable a password for an account. It will set the named account passwordless.
- -l OR –lock: Lock the password of the named account such as root. This option disables a password by changing it to a value which matches no possible encrypted value (it adds a ‘!’ at the beginning of the password)
- root : Lock and disable root account i.e. re-disabling your root account
Conclusion
By default, the root user account disabled in Ubuntu Linux so you can use the sudo
command to run commands with root-level access. You can log in as root directly after setting the root password.
If you have any questions or feedback, feel free to leave a comment.
Leave a Reply