How to Enable and Disable Root on Ubuntu?

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

On Linux, you need to know when the root account is enabled or disabled. Well, today you will learn how to enable and disable it in Ubuntu 22.04 Although short, this post can help you on more than one occasion.

When you install Ubuntu, during the process you are asked to create a personal account along with a password, but if you analyze well, you realize that you are not asked to create anything related to the root account.

However, the root account has been created, but without a password. Note that on Linux, if a user does not have a password, he is considered inactive and therefore cannot access the system.

So with this introduction and concepts, we can get started.

Enable and Disable the root account on Ubuntu

This procedure can be done temporarily or permanently according to the needs presented.

To do it temporarily, just open a terminal and write

sudo -i

You will be prompted for your regular user password and you will automatically become root.

Why temporarily? Because as soon as you exit the terminal, you will no longer be root.

exit

Or by closing the terminal window.

For many users, this method is sufficient for their needs. However, there are those who prefer to make it permanent.

Permanently enable root on Ubuntu

To enable the root user permanently, then you have to assign a password. Yes, that’s basically it.

First login as root user temporarily.

sudo -i

Now, change the password to the root user.

passwd root

Assign the password of your choice.

And that’s it!

Disabling the root account on Ubuntu

If you no longer want to have the root account active, then the best thing to do is to disable it.

To achieve this, first log in as root user and run

passwd -dl root

It is that simple to disable it again.

Conclusion

The root account is very sensitive, so it requires special care. I hope that with this post, you will be able to manage it in a better way.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook