Ubuntu – How to add theself back as a sudo user


I clean-installed Ubuntu 11.10 today, and then installed VirtualBox. This required me to add myself to the vboxusers group, and since 11.10 seems to no longer have a graphical app to add users to a group, I ran the following command:

sudo usermod -G vboxusers stephane

This is a problem. I now see what I should have run instead is:

sudo usermod -aG vboxusers stephane

The end result is I'm no longer in the groups I should be in. Including whatever group is required to run "sudo". When I run any command as sudo now, I get the following:

$ sudo ls
[sudo] password for stephane: 
stephane is not in the sudoers file.  This incident will be reported.

Is there a way to fix this, or do I need to re-install from scratch again?

Best Answer

    1. During boot, press and hold the left Shift key, and you should see the GRUB menu.

    2. Select the entry containing (recovery mode) and wait.

    3. You should now be presented with a menu. Select:

      remount    Remount / read/write and mount all other file systems 

      and wait for your file systems to get mounted with read/write permissions, then press Enter.

      If this option doesn't appear or won't work, you can instead choose the root option and use the following command to mount the system partition:

      mount -o remount /

      You can check out which is your system partition with fsck command or by viewing /etc/mtab.

      After successfully running the mount command (i.e. no error messages), proceed directly to step 5 below.

    4. After choosing the remount option, the menu comes up again. Select:

      root       Drop to root shell prompt
    5. Now enter one of the following commands to re-add your user to the admin group (for Ubuntu 11.10 and earlier):

      adduser <USERNAME> admin

      or to the sudo group (for Ubuntu 12.04 and later):

      adduser <USERNAME> sudo
    6. Reboot and you should be able to use sudo again.

  • Related Question