The way to find your how-to

View my LinkedIn profile

How to get user back to sudo group if root account is not active or password is unknown under Ubuntu Linux


As you probably know in Ubuntu 11.10 there is no graphical applet to add/remove users to/from groups and instead of this you have to use terminal and short command to manage them.

Unfortunately it is very easy to make a mistake and be removed from all the other groups.

The usual mistake is missing -a flag in the command below which will add you to the vboxsf group but... it will remove you from all the others!

sudo usermod -G vboxsf fred

If you want to be added to the vboxsf group but not removed from the other the command should looks like this:

sudo usermod -a -G vboxsf fred

or simply:

sudo usermod -aG vboxsf fred

If this happened, you are in the right place and continue to read.


It is not that hard to put everything back like it was before as your groups settings should be automatically saved to the backup file (/etc/group-).

Do the steps below and you will be a happy Linux user again.

  1. First we need to start system in the recovery mode:
    • Restart it  -> when you see the BIOS screen press shift button and hold it until you see the grub menu
    • Select recovery mode and press enter

  2. When Recovery Menu will pop up -> go arrow down to Drop to root shell prompt section -> and hit enter

  3. You should see command prompt similar to the below:
    root@hostname:~# _
  4. Enter the following command to remount file system from RO to RW:
    mount -n -o remount, rw /
  5. It is always good idea to make backup of the file we want to change:
    cp /etc/group /etc/group.bak
  6. And then overwrite existing group file with the previous version:
    cp /etc/group- /etc/group
  7. Check if your user is definitely assigned to sudo group:
    cat /etc/group |grep sudo
  8. If you see the line similar to the below everything seems to be ok and go to step no. 12:
    root@hostname:~# cat /etc/group |grep sudo
  9. If NOT -> edit the group file (you can use any file editor you like):
    editor /etc/group
  10. Find the line which starts with sudo:x: -> and add your username at the end of this line
  11. Save file and exit editor by pressing Ctrl+X ->then letter Y -> and enter
  12. Exit recovery mode by writing command:
  13. And finally exit Recovery Menu by selecting Resume normal boot and pressing enter

After these steps your system should starts normally and your user should be assigned to the sudo group again.

Document version: 1.2

Last modified on:


No comments yet
Notify me about new comments on this page
Hide my email
Powered by Scriptsmill Comments Script