Set password for root on virtualbox ubuntu

16

1

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!

rtfminc

Posted 2010-12-13T00:42:16.850

Reputation: 293

1Off-topic, but try sudo su. – None – 2010-12-13T00:51:21.463

Answers

22

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:

https://help.ubuntu.com/community/RootSudo

dsas

Posted 2010-12-13T00:42:16.850

Reputation: 346

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) – None – 2010-12-13T00:55:39.957

0

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.

dsas

Posted 2010-12-13T00:42:16.850

Reputation: 346

'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 – 2010-12-13T01:24:59.943

2The 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 – 2010-12-13T01:39:33.203

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 – 2010-12-13T01:41:28.897

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 – 2010-12-13T01:46:26.820

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 – 2010-12-13T02:11:48.263

Yes, which is accessed by selecting "recovery" mode in grub. – dsas – 2010-12-13T02:26:00.107

0

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)

YudhiWidyatama

Posted 2010-12-13T00:42:16.850

Reputation: 151

-2

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

sudo su

Enter password

osboxes.org

Syaiful Nizam Yahya

Posted 2010-12-13T00:42:16.850

Reputation: 97

(1) sudo asks for the user's password. What is "osboxes.org"? (2) The user doesn't have sudo access, so this will just result in an error message. – Scott – 2018-11-28T03:27:26.653

@Scott http://lmgtfy.com/?q=osboxes.org

– Syaiful Nizam Yahya – 2018-11-28T09:42:31.283

For some weird reason, the only way to become root in osboxes.org is the way that I mentioned. If its wrong, prove it. – Syaiful Nizam Yahya – 2018-11-28T09:47:39.033

OK, so they provide pre-made VMs for people who don't want to go through the hassle of installing them properly.  This information, if correct, may be valuable.  But somebody else agrees with me that it's not an answer to this question.  I suggest that you ask a new question about OSBoxes and post your answer there.  I'm not going to download software from a site of unknown trustworthiness, but I expect that dsas's answer regarding "rescue mode" / "single-user mode" will work on an OSBoxes VM.

– Scott – 2018-11-28T18:05:52.747