Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I loaded ubuntu into virtualbox. It all works well but it occurred to me that I was not asked (or did not setup) a root password. I want to use root on occasion, but I cannot seem to find out how to do this. I've tried to access the sudoers file as well as run visudo but have no authority without root!

Any ideas how to get or setup root password?

I do have a root user in /etc/passwd. The two accounts I have do not have authority to even manage groups, because it asks for root password and I don't know it!

share|improve this question

migrated from Dec 13 '10 at 0:57

This question came from our site for professional and enthusiast programmers.

Off-topic, but try sudo su. – casablanca Dec 13 '10 at 0:51
up vote 13 down vote accepted

Ubuntu uses sudo by default. If you preface your command with "sudo" it prompts for your user password and then runs it as root. To get a root session use:

sudo -i

To enable the root account, open a terminal and run the following to set a root password:

sudo passwd root

For more information see:

share|improve this answer
Just to extend slightly (and summarise the link above), by default you cannot log in as root in Ubuntu, but it is possible to set a root password but is not recommended (or actively discouraged) – David O'Meara Dec 13 '10 at 0:55

Did you use a pre-existing virtual box image or install from cd/iso ? If you installed from someone elses image then there may be a "ubuntu" user that has sudo privs. Check the documentation.

Alternatively boot into rescue mode and add your 'rob' user to the admin group.

share|improve this answer
'rescue mode' is for disaster recovery, not adding users to the admin group. A 'visudo' command or 'sudo vi /etc/sudoers' should be sufficient. – Wesley Rice Dec 13 '10 at 1:24
The problem is that the OP doesn't have sudo access, he cannot fix that by running visudo or sudo vi /etc/sudoers as they both require that he has sudo access. – dsas Dec 13 '10 at 1:39
No, the problem is that OP doesn't know the root password- "it asks for root password and I don't know it!", to quote. Booting into rescue mode won't get him anywhere. – Wesley Rice Dec 13 '10 at 1:41
There generally isn't a root password on Ubuntu. The OP has clarified that the user accounts he does have access to don't have sudo access. Booting in rescue mode as far as I remember gives the option to start a shell as root where he can reset the root password or give sudo access to one of the other user accounts. – dsas Dec 13 '10 at 1:46
Oh, in that case you're talking about single-user mode, which isn't the same as 'rescue mode', where you typically perform rescue operations. – Wesley Rice Dec 13 '10 at 2:11

I agree with dsas : Boot into rescue mode, then add the user to admin group :

  1. Restart the virtual machine. Hold Shift during boot. Select Recovery mode when menu shows up. The system will not ask for any password.

  2. Type these

usermod -G admin rob

Now rob has admin permissions, you could restart the virtual machine ('reboot'), and run 'sudo su' to access root shell (the system would ask for rob's password, not root's password)

share|improve this answer

You must log in to answer this question.

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