The Art of Losing and Regaining Privileges

by Evil Roda

Originally posted on Tumblr on March 19, 2017

So on Thursday, I ended up losing my sudo privileges. Friday night, I gained them back. What am I talking about? Welll…

Okay, so Thursday morning, I looked at my Pocket CHIP and realized I hadn’t used it in a while. Looking to change that I turned it on and tried to run an update. It was then that I realized I had forgotten the root password, so I thought I would just reflash it and start over. Now, to reflash your CHIP, you use a piece of software called CHIP Flasher, which is a Chrome app. On Linux, use of this software requires a one-time setup process involving a change in your permissions, outlined here. First mistake was assuming the instructions were just generically for Linux. They were not. They were actually specifically for Ubuntu; I am running Solus.

So I run the first command. That works. Then I run the next command. It says that the plugdev group is not available. At this point, I am listening to music on my headphones, connected to my laptop via a USB headphone adapter because my headphone jack on my laptop broke. So I realize the commands are for Ubuntu, and decide that I finally should get around to reinstalling Linux Lite on my netbook. I unplug my adapter because it’s so bulky, I can’t plug anything else in (my mouse is occupying the port on the other side), and try to plug in a thumb drive to make it a Linux Lite live CD. Computer doesn’t recognize it. I try again with a different thumb drive. Nothing. I plug it into my netbook with Solus booted up. Works on that one. What? I try my headphone adapter in my big latop. Doesn’t work. Shit.

At that point, I realized I was pretty fucked. After trying the complete instructions in a desperate attempt to see if that would fix the issue (it didn’t), I hopped on the unofficial Solus Discord and got help from a South African dude. We started troubleshooting, and apparently I had fucked with the groups? I’m actually still not entirely sure what the initial issue was. For future reference, to see what groups you’re in, you type in groups, and the output should look like:

evilroda@hpav ~ $ groups
evilroda dialout audio video cdrom lpadmin sudo fuse

Basically, you need to be in the dialout group to use USB devices. Now, I was still in dialout, in fact, what you’re seeing there is the exact output I pasted into the Discord chat, so I have no idea what the issue actually was. However, after a while trying to troubleshoot this, I looked at the man page for the usermod command and found this little gem:

-G, –groups GROUP1[,GROUP2,…[,GROUPN]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no intervening whitespace.
The groups are subject to the samerestrictions as the group given with the -g option.
If the user is currently a member of a group which is not listed, the user will be removed from the group.
This behaviour can be changed via the -a option, which appends the user to the current supplementary group list.

I thought, hey, maybe if I just did the same command, but without -a, once to take me out and once to put me back in the group, it might work! And to my surprise, after logging out and back in, it did! Unfortunately, there was another issue. I’ll let what I posted in the Discord chat explain it for you…

So I fixed the USB problem.
We may have another issue, though.
evilroda@hpav ~ $ groups
evilroda dialout
Kill me.
evilroda@hpav ~ $ sudo nautilus
Password:
evilroda is not in the sudoers file. This incident will be reported.
PLEASE KILL ME

Yes, that’s right. I revoked my own damned sudo privileges. As the man page posted above explains, when you use -G without -a to put yourself in a group, it takes you out of every other group. I was even more fucked than when I started.

For those of you who don’t know, the command sudo stands for “super user do,” and allows you to do administrative level tasks, like installing software, or running updates, or accidentally wiping your hard drive. Note that even if you use a program like the Solus Software Center, if you do not have sudo privileges, then you can not install software, as it still uses those privileges to bar access from people who shouldn’t have access to your system. So basically, I could still use my computer, I just couldn’t administrate it. This is a pretty big issue.

Funny enough, this is actually an easy fix, as there’s loads of guides on how to do this! Just reboot, and on the GRUB screen, hit shift and… Stop. I’m not using GRUB. Much to my dismay, after looking up how to fix it and rebooting, I saw not the GRUB bootloader screen, but a UEFI bootloader screen. Basically, GRUB loads your operating system, and, if you’re running multiple operating systems, lets you choose which one you want to load into. Most Linux operating systems have a recovery mode in GRUB that will let you fix your lack of sudo privileges. However, there is no UEFI bootloader that everybody uses, as far as I know, whereas everybody not on UEFI uses GRUB (or LILO, but usually GRUB). Now, Ubuntu’s UEFI bootloader has a recovery mode, I know this because I looked it up and saw how to get into it (you press escape). I don’t even know if Solus’s UEFI bootloader has a recovery mode; if it does, I can’t find it.

So at this point, I went out with some friends to hang out and play Magic at our local gaming store. Before I did, I post on the Solus forum about the issue, After I got back, I went through some troubleshooting with a Norwegian on the Solus Discord, nobody had posted on the forum thread as of yet. His solution involved booting into a live CD and chrooting and stuff I didn’t really understand, and, long story short, didn’t work. I was thinking about just reinstalling the whole damned OS, which, while I could do it, and do it without data loss, would be a pain in the ass.

However! Friday night, I got back home from work and saw there was a reply from someone on the forum thread! All I needed to do was boot into a live CD, mount my hard drive, find the group file, and edit myself into the sudo group! After looking up some instructions on going about all that, it worked! You can find a complete walkthrough of what I did on the thread here, but I’ll just leave it at the fact that it worked and I can administrate my system again.

Now, I’m sure some people are going to point to this and say, “Hah! You see? Linux IS hard! You don’t have these issues on WINDOWS! OR MAC!” And to that I say, you’re full of shit. I’m just some average guy. When I first started using Linux, I didn’t know a thing about it, and now people look at me like I’m a computer wizard when I talk about this stuff (I actually am a computer wizard, an evil one, but that’s beside the point). My point is, all I did was read up on this stuff. Everything you do wrong on Linux, you can recover from, even if it involves reinstalling the system. Depending on the distro, I can install it in a snap, and I can definitely install Solus with no issue at all. Hell, I can even back up my data right before I reinstall using the live CD. I don’t know what the process is for reinstalling OSX, but Windows is hard to install. I mean, it’s easy initially, but it takes a long time, and then you have to hunt down drivers and do all this setup, it’s just a pain, and for a system that doesn’t tell you everything. Linux does. Even if you don’t understand it, somebody else does and can help you. So if you read this and got scared of using Linux, don’t be. I can assure you that, while I have had problems with Linux, I’m not going back to Windows, and I’m definitely not buying a Mac. In fact, let me put it this way. Windows (and, for the short time I used it, OSX) made me feel powerless. Linux makes me feel powerful.