46

I was asked for root credentials to setup my printer in Ubuntu. This seemed to be caused by a bug. And the suggested workaround is to create a root password. Since it is default that no root password is used in Ubuntu, i wonder how i could revert this changes.

Once i have set a password for root, is there a method to disable it again?

80

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.

  • 7
    Use sudo passwd -S root to check if locked or not (will have L in output instead of P). – Wtower Jun 22 '15 at 10:07
  • 1
    Which version did they make this change on? – Timothy Swan Jan 12 '18 at 22:00
29
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.

  • I don't get it. Why an unusable password? – Tshepang Jan 7 '11 at 12:54
  • Unusable in that you cannot log in with it. It's what the password starts off as AFAIK. – Oli Jan 7 '11 at 12:56
  • 1
    when i disable it with: sudo passwd -l root. do i have to remember the current root password for future use, perhaps if i someday want to activate root password again? – NES Jan 7 '11 at 13:16
  • 3
    @NES no you dont have to remember it. you reset the password and time with "sudo passwd" – binW Jan 7 '11 at 14:01
  • 1
    The first command will return the /etc/shadow file to its out-of-the-box state, which seems like maybe the better approach of the two. – njbair Mar 16 '17 at 14:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.