Switching to Root Temporarily
By assigning sudo rights to everyday users, Ubuntu users are encouraged to conduct server administrative tasks. Registered users can run programs as another user, normally the root user, using the sudo command.
The sudo community is now a part of the initial user generated by the Ubuntu installer. It's likely that the person you're now logging in as has administrative rights. To briefly escalate root user rights, run the following command with the sudo prefix:
The very first moment you use sudo in a process, you'll be prompted for the user password.
To briefly switch to the root account in the current login session, use sudo su or sudo -i commands and insert the user password:
To ensure that the user has been updated as root, use the whoami command:
Modifying Root Password
Since the root user has been disabled, this does not imply that the root account has been deleted. Since the root account has no password, logging in as root is not feasible.
All users have to do is open the root account to create a password for the system administrator. The passwd command in Ubuntu allows you to set or change a user account's password. When generating the password, make sure to use a strong and exclusive password.
The most critical part of your account's protection is using a secure password. A good password usually consists of at least sixteen characters, an uppercase letter, a lowercase letter, an integer, and a special character. To change the root user's password in Ubuntu, type the command given below as a sudo user:
sudo passwd root
You will be asked by the following command to enter and confirm the new root password. You will be prompted to retype it again. When you enter the password, it does not appear on the page. When you have successfully entered the new password, you will see the following output:
passwd: password updated successfully
The password for the root account has been updated. Users can now sign in to the Ubuntu system as root using the latest password.
The root account in Ubuntu has no password by default. The sudo command is recommended for executing commands with root privileges. Before you could even log in as root, you will be needed to set the root password. We hope that the given information will help you to understand why the root user is not enabled by default.