Thursday, April 18, 2013

The day I lost root privileges

I have (K)ubuntu 12.04 Precise Pangolin installed on my Fujitsu Lifebook UH75/J (I've discussed about it in one of my previous posts). Needless to say, the experience was nice. It was the first time I ever used KDE as my primary DE for everyday use. I had used KDE on my desktop, but never thought about using it full-time, as I only switched to it whenever Unity felt a little boring.

Anyway, fast forward a couple of weeks, and suddenly I found myself unable to run commands with root privileges (with the `sudo' command). Every command which I prefix with `sudo' gets denied with a message telling me I was not in the sudoers file and that the incident shall be reported (gee, I wonder to whom they actually report these to). Frustrated, I've decided to log in directly as root with `su'. Then I remembered that Ubuntu, for some odd reason, does not allow logging in as root by default.

Instinctively, I turned to searching for solutions online. One solution told me to log in to Recovery Mode, log in as root from there, and then add myself back to the sudoers group. But even if I managed to do that, I still haven't answered one important question. How and why was I removed from the sudoers group in the first place? I don't remember intentionally nor accidentally revoking my own sudo privileges from myself. While trying out the solutions I have found, I thought of the reasons for my disappearing privileges in the background.

Then the realization hit me. I don't recall exactly how, but I remembered how exactly I lost my user privileges when I saw a command telling people how to add themselves into the `sudo' group (the group of users in an Ubuntu system who has sudo privileges). Quickly, I used the `groups' command to check what groups in my notebook I'm part of, then the horror showed up in my face:

aldo : vboxusers

Then I remember it all now. I was trying to get Virtualbox to work on my new ultrabook some time ago, and one of the things I had to do was to get USB devices to work from the host machine to the guest machines. It would involve having me put myself in the special `vboxusers' group, but because I don't really memorize console commands that well unless I have to use them a lot, I used a variant of the `useradd' command, which puts me in the vboxusers group ONLY, instead of appending the vboxusers group to the groups in which I belong to. I forgot that the `gpasswd' command was a much better solution when it comes to adding groups. I'll try to keep this in mind since I'll probably be administrating other people's boxes in the future. Screwups increase exponentially in severity the more users become affected by one's mistake.

Since Ubuntu doesn't allow root logins unless you were to go to recovery mode, I've decided to reboot into recovery mode, however, there was a conflict with the inteldrmfb and Vesa VGA drivers. After more frantic Googling, I removed `nomodeset' temporarily from the launch options of the recovery boot and I was immediately put into recovery mode. I proceeded to login as root, checked out all the available groups in `/etc/group' and `/etc/passwd', then added myself to the sudo group and other groups which I think I should be part of.

After rebooting, I was relieved to find that I now have my sudo privileges back. The world seems strange when you don't have root privileges, doesn't it?

I haven't told you about my Plan B: In case I get tired of fixing my problem, which usually never happens, I would replace Ubuntu with openSUSE since I was itching to try it out, and since I have quite a lot of free time this Philippine summer to reconfigure my system. However, since I have already fixed the problem, I don't feel the need to replace Ubuntu anytime soon. Perhaps I'll just move when another seemingly insurmountable problem arises.