Set password for root on virtualbox ubuntu

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!

1

5 Answers

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:

3

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.

6

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)

Nizam is correct. I have virtual box with ubuntu 20.04 installed on ubuntu 18.04 and it worked for me. I did following:

osboxes@osboxes:~$ sudo su
root@osboxes:/home/osboxes#

I don't know why he is given -2. I have reduced -2 to -1.

Zulfi.

If you're on osboxes image, for Ubuntu try this in terminal:

sudo su

Enter password

osboxes.org

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like