enable and disable root account

How to Enable & Disable Root User in Ubuntu

In some Linux systems such as Ubuntu/Debian, root user is disabled by default for security purposes. But sometimes you may need to enable root user on your system. In this article, we will look at how to enable & disable root user in Ubuntu.


How to Enable & Disable Root User in Ubuntu

Here are the steps to enable & disable root user in Ubuntu.


Sudo Access

Before we enable or disable root account, it is important to know that only users with sudo access can enable or disable root account. Sudo is a user group that gives administrative privileges to users, to be able to perform system tasks or run programs as root.

Members of the group sudo already have sudo access. If you want to grant sudo access to another user, just add them to this group with the following command.

$ usermod -aG sudo username

Once the user is granted sudo privileges, they can easily run other commands with elevated privileges, by prefixing them with sudo keyword.

$ sudo command


Enable Root User in Ubuntu

If you want to enable root user in Ubuntu, you need to simply set a password for root user. You can do so with passwd command. But please note, if you are a regular user, you can only change your own password. If you want to be able to change root password, you need to be logged in as user with sudo privileges.

If you have sudo privileges, run the following command to change root password.

$ sudo passwd root

You will be prompted to enter new password.

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Please note, the new password you type will not be displayed on your screen.

After successfully changing root password, you will be able to login as root user.


Disable Root User Account in Ubuntu

If you want to disable root user account in Ubuntu, just set its password to expire, with the following command.

$ sudo passwd -l root

In this article, we have learnt how to enable & disable root account in Debian/Ubuntu Linux. Please be very careful before enabling root account. Most operations on Ubuntu/Debian systems don’t require root access, it is highly recommended to leave it disabled if possible.

Also read:

How to Check RAM Size in Linux
How to Disable SELinux in CentOS
MySQL Row Number & Its Uses
How to Comment Multiple Lines in MySQL
How to Install Mumble Server in Linux

Leave a Reply

Your email address will not be published.