How to Enable and Disable Root User Account

As a new linux user, you may wonder how to log in to your system as a root user or what is the default root password. In Ubuntu/Debian Linux, the root user account is disabled by default for security reasons.

This tutorial explains how to enable and disable the root user account in Ubuntu Linux.

Sudo Users

Ubuntu users are encouraged to perform system administrative tasks by granting administrative privileges to a regular user using a tool named sudo. Sudo allows authorized users to run programs as another user, usually the root user.

By default on Ubuntu systems, members of the group sudo are granted with sudo access. The initial user created by the Ubuntu installer is already a member of the sudo group. Chances are that the user you are logged in as is already granted with administrative privileges.

If you want to grant sudo access to another user, simply add the user to the sudo group:

usermod -aG sudo username

To temporarily elevate root user privileges, run the command prefixed with sudo:

sudo some-command

The first time you use sudo in a session, you will be prompted to enter the user password.

If you want to run a command with sudo privileges without entering the password, you’ll need to edit the sudoers file. To do so type visudo:

sudo visudo

This will open the /etc/sudoers file with your favorite command line text editor. Add the following line by replacing username with your username:

/etc/sudoers
username ALL=(ALL) NOPASSWD: ALL
Copy

Enable Root User Account in Ubuntu

If for some reason, you need to enable the root account, you just need to set a password for the root user. In Ubuntu and other Linux distributions, you can set or change the password of a user account with the passwd command.

As a regular user in Ubuntu, you can only change your own password. The user you are logged in as must have sudo privileges to be able to set the root password.

To enable root account in Ubuntu, run the following command:

sudo passwd root

You will be prompted to enter and confirm the new root password

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

The password is not shown on the screen when you type it.

That’s it! You have successfully enabled the root account. You can now log in to your Ubuntu machine as user root using the new password.

Disable Root User Account in Ubuntu

If you previously enabled the root user in Ubuntu and now you want to disable it, set the root password to expire.

To disable the root account password, use the following command:

sudo passwd -l root

Conclusion

To enable the root user account in Ubuntu, all you need to do is to set the root password.

When setting the password, make sure you’re using a strong and unique password. Having a strong password is the most important aspect of the security of your account. Often a strong password has at least 16 characters, at least one uppercase letter, one lowercase letter, one number, and one special character.

If you have any questions or feedback, feel free to leave a comment.

You may also like to read Enable SSH root login on Debian

  • enable root, disable root, PermitRootLogin
  • 69 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

How to Set Up a Mac for Your Kids

Providing children with access to a computer and the internet is increasingly important, but so...

How to Get Help With a Command from the Linux Terminal

Whether you’re an inexperienced terminal user or a grizzled veteran, you won’t always know the...

How to change the ssh port on Linux

To Change the SSH Port for Linux Server Connect to your server via SSH Switch to the root...

How To Install screenFetch in Linux

If you've browsed Linux groups on social media, you've probably seen a lot of screenshots that...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

Powered by WHMCompleteSolution