How to restore sudo privilege with Linux live CD

linuxlinux-mintlivecdrootsudo

I'm running Linux Mint 11 and I lost the privilege to use sudo, apparently the result of accidentally removing myself from the admin group.

When I use the groups command to list the groups I'm in, it only shows my user ID and vboxusers. I think I mistakenly used usermod instead of useradd to put my ID in the vboxusers group, so I got removed from all other groups.

Solutions I found on the web (like this: http://www.psychocats.net/ubuntu/fixsudo) describe choosing recovery mode in the GRUB menu, getting a root prompt and using that to add my user back to the group. But when I do that it asks for the root password, which I don't know because Linux Mint and other Ubuntu-based distributions don't allow you to see or set the root password during installation.

I have Linux live CDs so I can gain root privileges that way, but that won't enable me to manipulate users in the Mint installation via the command line. However, I can use that to edit any file, so which file should I edit and how should I edit it so I can regain admin (and consequently sudo) privileges?

My ID is still in the sudoers file, as shown with cat /media/mint/etc/sudoers when running the live CD.

Best Answer

You'll have to boot into recovery mode to gain root (system-wide) access in order to repair

If you have a single-boot (Ubuntu is the only operating system on your computer), to get the boot menu to show, you have to hold down the Shift key during bootup.

From the boot menu, select recovery mode

After you select recovery mode and wait for all the boot-up processes to finish, you'll be presented with a few options. In this case, you want the Drop to root shell prompt option.

/etc/group is the file that defines the groups on the system

You can then use adduser username admin to readd your user to the admin group.

Alternatively you can use the vigr command to edit the /etc/group file safely

format example;

group-name:x:group-number:user1,user2
admin:x:110:username
Related Question