Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I accidentally removed myself from the admin group when editing the user. Now I can no longer use sudo. The error says: ber is not in the sudoers file. This incident will be reported.

I booted up in rescue mode, but, when going into root prompt, it asks me for the root password. I don't have one, and providing with my own (first and only ubuntu-user) password, it won't allow entrance.

My harddisk is encrypted, but only the /home/user part, not the entire disk, afaik.

What can I do?

share|improve this question

marked as duplicate by Eliah Kagan, Thomas W., Eric Carvalho, Nathan Osman, Basharat Sialvi Apr 9 '13 at 1:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers 2

up vote 6 down vote accepted

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):


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.

share|improve this answer
IMHO, you have to mount at least /dev and /proc to get a running bash in a chrooted environment, but I may be wrong. –  FUZxxl Mar 4 '11 at 15:02
@FUZxxl You're probably right, I've only ever done it to do fix a bootloader so that needed /dev mounting. I'll update it with a full compliment (mounting too much won't hurt) –  Oli Mar 4 '11 at 15:15
There is no need to chroot the filesystem, you can modify /etc/group manually. If I'm not mistaken, a backup of the group file is also written to /etc/group-. –  Lekensteyn Mar 4 '11 at 15:27
@Lekensteyn Yeah the that was the first suggestion I gave. Note the path won't be /etc/group because that would refer to the LiveCD's version. I gave chroot as an option because it's not wildly difficult and should still work. –  Oli Mar 4 '11 at 15:46
Sorry for the confusion, by /etc/group, I meant the /etc/group of the mounted partition, like /mnt/etc/group. –  Lekensteyn Mar 4 '11 at 15:50
show 2 more comments

At the grub boot-up menu, press e to edit the kernel launch command-line and append the word single at its end. This should boot the system on single-user mode (as root) and allow you to perform any modifications.

share|improve this answer
This is good, quick and easy but does not always work. –  Ashu Nov 25 '12 at 6:21
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.