The root user (or super user) is a special user account on all Linux and Unix systems. It has access to all commands and all resources on the system without any restrictions.
If you are switching to Ubuntu from another Linux distribution, you may wonder what the default root password is or how to change the root password. By default, on Ubuntu, the root user account is disabled for security reasons.
This guide explains how to temporarily modify the root user account and how to modify the root user password on an Ubuntu system.
Ubuntu users are encouraged to perform sudo privileges through normal users before performing system management related tasks. Sudo allows authorized users to run programs as other users, usually the root user.
The Ubuntu installation is a member of the sudo user group by default. It is possible that the user you logged into the system has been granted administrative rights.
To temporarily elevate the root user's authority, add sudo
before the command:
sudo command-name
The first time you use sudo in a session, you will be prompted to enter the user password.
In the currently logged-in session, to temporarily switch to the root account, you can use the sudo su
or sudo -i
command, and then enter the user password:
sudo su -
Run the whoami
command to verify whether the current user identity has been changed:
whoami
root
The root user is disabled by default, but it does not mean that the root user account is removed. It is impossible to log in with the root account, because the root account has no password set.
If for some reason, you need to enable the root account, all you need to do is set a password for the root user. In Ubuntu, you can use the passwd
command to set or change a user's password.
To change the password of the root user in Ubuntu, run the following command as a sudo user:
sudo passwd root
You will be prompted to enter and confirm the new root user password.
When setting a password, please make sure that the password you use is a unique and strong password. Having a strong password is the most important part of account security. Usually a strong password has at least 16 characters, at least one uppercase letter, one lowercase letter, one number, and one special symbol.
When you enter the password, the password will not be displayed on the screen:
Enter newUNIX password:
Retype newUNIX password:
passwd: password updated successfully
And that's all! The root account password has been changed.
Now you can log in to your Ubuntu system with the root account and the new password.
By default, in the Ubuntu system, the root account has no password. The recommended way is to use sudo
to run root-level commands.
To log in directly as root, you need to set a root password.
Recommended Posts