Ducksec Mar 09, 2024 ubuntu, troubleshooting

Ubuntu: How Do I Access The Root User On VirtualBox

I recently ran into another interesting “bug” (I sure do seem to find a lot of them) although this one, to be fair, is more of a quirk than an actual error.

As I often seem to need to do at the moment, I was spinning up a new Ubuntu instance in VirtualBox. VirtualBox v7 has a fancy new feature called “Unattended Installation” which I hadn’t previously either noticed or had cause to use. I thought I’d give it a try and found that it did, indeed, set my system up using the credentials that it asked me for, and even installed the Guest Tools. What’s not to love?

Well, how about the fact that on booting I’m not root and have no idea of the root password. No problem - let’s sudo su… and no, password prompt. sudo -s? No, password prompt. sudo [the command I wanted to run] - password prompt. Shoot. I’ve no idea what the root password is. It turns out that VirtualBox 7’s “Unattended Installation” does not put your initial userid into the sudo group - instead, it sets the root (uid=0) password to the same password as the initial id (uid=1000).

The solution is therefore to run su - and use the password you specified when kicking off the installation. Then add your user to sudoers with usermod -a -G sudo [username].

This is a really weird way of going about this - VirtualBox, if you’re reading - Love the unattended installation option, don’t love this setup!