I ran into a similar issue as the only administator of my machine. If you have another administative user, jena's answer is an easier way.
I was really helped by an anwser on askubuntu about resting a lost administrative password. https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
Full steps :
##Full steps :
YouYou need to boot into recovery mode.
Boot up the machine, and after the BIOS screen, hold down the left Shift key. You will then be prompted by a menu that looks something like this:
I've noticed on some systems that timing when to hit the left Shift key can be tricky, sometimes I miss it and need to try it again.
If you have full disk encryption, you have to hold down the key before being asked for the disk password. (You will be asked for the password in a command line interface during boot).
Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.
Now you should see this menu:
Using the arrow keys scroll down to root and then hit Enter.
You should now see a root prompt, something like this:
root@elementary:~#
At this stage you should have a read-only filesystem. You have to remount it with write permissions:
mount -o rw,remount /
Now we can set the user back into the sudoers group with the adduser
command. (In this example I will use jorge as the example, you need to substitute whatever the user's username is):
root@elementary:~# adduser jorge sudo
Now you can reboot, and you should be able to use sudo commands. You should make sure that you are part of following groups :
- adm
- sudo
- lpadmin
- sambashare
- jorge (your username)
jorge@elementary:~$ groups
You can add your user back in these groups with sudo
jorge@elementary:~$ sudo adduser jorge adm