In Ubuntu system, root user account is disable by default for improve security of system. At the installation time of Ubuntu Linux the root user is creating automatically but not asking to set password for root user. In Linux, a user account without password or empty password is considered as a disabled account.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux System queries.
In this context, we shall look into how to enable and disable root user account in Ubuntu Linux System.
Generally, a regular Ubuntu user can perform administrative tasks by granting administrative privileges known as sudo. Sudo enabled users are authorized to perform same as root user account.
To grant a sudo access to a normal user you just have to make member of sudo group. In Ubuntu, members of sudo group have permission of sudo access. By default, initial created user is already member of sudo group so that user have sudo access.
If you want to create a sudo user on your Ubuntu system follow this guide.
How to Enable Root User Account in Ubuntu ?
To enable the root user you just have to set password for root user. You can set password for a user account using passwd command. As a initial user account you should have sudo privileges to change password of another users.
Run the below command:
$ sudo passwd root
After that, It will prompt you to enter password and confirm password for root user account as given below:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
It's strongly recommend that you set strong and unique password. It is a most important security aspect of your system. Your password should have at least 14 characters and contains one uppercase letter, one lowercase letter, one number, and one special character.
Finally, you have successfully enabled the root account by setting up password.
Now you can login as root user on your Ubuntu server.
How to Disable Root User Account in Ubuntu ?
If you have enable root user account on your Ubuntu system and want to disable then simply set the password to expire. Execute the below command:
$ sudo passwd -l root
This article covers how to enable and disable root user account in Ubuntu system. Considered the most privileged account on a Unix system, root can perform any tasks needed for system administration.
Navigating a specific folder, killing any process or deleting a directory, root is so powerful that it has to be managed properly.
In order to change the root password, you have to use the "passwd" and specify the root account:
$ sudo passwd root
After changing your password, the account will be automatically unlocked.
In order to switch to the root account, you can use the well-known "su" command without any arguments (the default account is root):
$ su -
To restart your SSH server for the modifications to be taken into account:
$ sudo systemctl restart sshd