Disable root account in Ubuntu?

According to Ubuntu online help

Ubuntu developers made a conscientious decision to disable the administrative root account by default in all Ubuntu installations. This does not mean that the root account has been deleted or that it may not be accessed. It merely has been given a password which matches no possible encrypted value, therefore may not log in directly by itself.

If you want to enable root account simply give it some password using

sudo passwd

When you enter this command you will be asked for new password. The password you enter will be the password for root account so be careful and choose a strong password.

To disable the root login use

sudo passwd -l root

This will disable the login using root user name i.e your system will be back to previous state.

If you want more information on Ubuntu user management read the official documentation.


sudo usermod -p '!' root

That will set the root account to have an unusable password.

You can also lock the account to stop people logging in.

sudo passwd -l root

Either approach should do what you want. You don't need to do both.

Tags:

Root

Password