0

I removed (distrattament) my "sudo" user from sudo group user, I can't use root because I don't know a password for root.

I have an Ubuntu virtual machine and when I open Recovery Menu is limited read-only menu. If I select "root Drop to root shell prompt" the message is "Give root password for maintenance" ... but I don't know the root password.

How can I reset root password?

2 Answers 2

3

To recover the root password, you will need to boot into single user mode. In many distrobutions there is a drop down option to let you select at the boot loader. If you are using GRUB, you can select the version of the OS kernel you would like to boot, hit the "edit" key (e I believe), and then append the word "single" to the end of the kernel parameters string. You can find Ubuntu specific instructions here.

Once you have booted into single user mode, you should see a prompt like this:

sh#

To reset the root password, type:

passwd root

At this point you will be prompted to enter a new password and to confirm the password. You can also modify the /etc/sudoers file to add your user back to the sudoers group.

4
  • 2
    Note, you should modify the /etc/sudoers file and add yourself back to sudoers instead of enabling the root account. The root account is disabled for a reason. Apr 25, 2013 at 15:22
  • I disagree on that front - I work on Solaris, HPUX, and Red Hat boxes all day, and we have never had an issue with root login being enabled. Especially given a lot of apps we run require root SUID. If someone has absolutely no idea what they are doing, maybe it is a valid precaution. But I tend to consider it security by obscurity - the root account still exists (and you can exploit up to it), the wheel group still exists. Different approaches I guess :)
    – Matthew
    Apr 25, 2013 at 16:06
  • 2
    @Matthew: Which means you really aren't the target market for Ubuntu. The Ubuntu wiki has a good breakdown of the advantages and disadvantages of using sudo over root.
    – wersimmon
    Apr 25, 2013 at 16:11
  • @Matthew: Single user mode can be disabled. Solaris, HP UX and Red Hat are enterprise-class Unix where such ability is considered as an exploit and therefore disabled.
    – X.LINK
    Oct 3, 2014 at 0:11
-2

There are some changes in the procedure of resetting the root password in CentOS7. Reset the root password in CentOS

2
  • 1
    CentOS <> Ubuntu.
    – Mathieu K.
    Feb 5, 2018 at 22:30
  • 1
    Also, broken link. May 19, 2020 at 10:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .