Hmm well you've covered what I would have suggested first. Seems annoying that Rescue mode would hassle you for a password if the entire disk weren't encrypted (I don't know, that might be standard protocol).
I'd personally jump into a live environment (via Live CD or Live USB), mount the filesystem (assuming it isn't encrypted) and edit its etc/group
file and add yourself back in. The resulting line should look something like this (though the GID may be different):
admin:x:115:oli
Or on Ubuntu 12.04, find the line for the sudo
group instead of the admin
group.
Alternatively, you can probably chroot
from the LiveCD to run commands. (sudo password for the LiveCD is a blank password, just press return when prompted)
sudo mount /dev/sdYY /mnt # change sdYY to your root partition
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
sudo adduser your-username admin
For Ubuntu 12.04 and later, add the user to the sudo
group instead of the admin
group:
sudo adduser your-username sudo
chroot
drops you off at a root shell inside your filesystem so should let you do fancy things like adding users to groups. It's most useful for fixing boot issues but it can do a lot of gubbins.
/etc/group
manually. If I'm not mistaken, a backup of the group file is also written to/etc/group-
. – Lekensteyn Mar 04 '11 at 15:27/etc/group
because that would refer to the LiveCD's version. I gavechroot
as an option because it's not wildly difficult and should still work. – Oli Mar 04 '11 at 15:46/etc/group
, I meant the/etc/group
of the mounted partition, like/mnt/etc/group
. – Lekensteyn Mar 04 '11 at 15:50sudo gedit /media/10...e3/etc/group
. Added myself (ber) to adm,dialout,cdrom,plugdev,lpadmin,admin and sambashare – berkes Mar 04 '11 at 20:38sudo mount --bind
commands are necessary. I've just tested on 15.04 to verify that a simple chroot, with no extra mounts except/
, is (still) sufficient to add a user to a group, or change a password, from a live environment./dev
,/dev/pts
,/proc
, and/sys
, do not need to be mounted in the chroot for theusermod
,adduser
, andpasswd
commands to work. (sudo
is also not necessary in the chroot--i.e., when runningadduser
--as one already has a root shell.) – Eliah Kagan Apr 30 '15 at 09:22