If you cannot get Terrance's solution to work, you can use the live environment from a cd. You will want to mount your /
(root) partition, chroot into it, and use the normal tools to fix your user account.
Detailed guide
Reminder
Never blindly run commands you find on the internet, especially not while you have root access. Some commands can cripple or even destroy your system. If you do not know what a command or its arguments do, look it up in the man pages first, and only run it once you understand what the command will do. If you do not know how to use the man pages, see http://linux.die.net/man/1/man or $ man man
Set up live environment
Boot into your live environment and open up a terminal (konsole, gnome-terminal, etc), and switch to the root user if you're not already.
Find your root partition in /dev
. Running # lsblk
may help you identify it, especially if you know its size. From here, I'll assume your root partition is on /dev/sda1
.
Now mount your root partition with # mount /dev/sda1 /mnt
. Technically, you don't have to mount it to /mnt
, so if you prefer, mount it somewhere else that is empty. If you're not sure that you mounted the right device, do # ls /mnt
. If it's the right device, you should see folders like home
, etc
, usr
, var
, etc.
If it's the wrong device, make sure you're not in /mnt
, then run # umount /mnt
.
Once you have your root partition mounted to /mnt
, chroot into it with # chroot /mnt
. You should now be working with your installed system.
Fix your user account
Assuming your admin group is called wheel
, you can add yourself back to it with # usermod -aG wheel your-user-name-here
. At this point, you may also want to double-check your sudo config, provided you know how to use visudo
.
When you're done fixing up your system, run # exit
to leave the chroot environment, and unmount the partition with # umount /mnt
. You can now reboot back to your normal system, and check that your access has been restored.