I have been using Precise Pangolin and I am into a problem now :( I was trying to add my current user to the group vboxusers.. So I used the command,

sudo usermod -G vboxusers myusername

And it got succeded too. But after adding like that, I am unable to perform any sudo operations. Whenever i use a sudo command I get an error message stating "myusername is not in sudoers file".

I tried enabling root account also. But I couldn't. How to fix this issue?


As enzotib comments, a good way is to restart in recovery mode and write

for i in adm cdrom sudo video plugdev lpadmin; do adduser myusername $i; done

Substituting myusername as required. This will add you to all the important groups, including sudo, which gives you access to sudo.

  • 2
    A less complex command is sudo usermod -a -G adm,cdrom,sudo,video,plugdev,lpadmin myusername. – Eliah Kagan Jul 29 '12 at 21:04
  • Thank You guys. :) I have not tried the above mentioned solution. Will let u know whether it worked or not, once after i try :) – Hariharan Jul 31 '12 at 9:31
  • Thankyou guys. It is working :) :) Linux rocks and Linux users Rock to the core :) – Hariharan Jul 31 '12 at 13:02

Unfortunately that command do the wrong thing, because gives you only that group and removes all others. usermod should be avoided, there are better and simpler tools to use.

The solution is to start in recovery mode and add your user to the sudo group.

To add a user to a group, I usually use

sudo gpasswd -a $user $group

many others prefer to use

sudo adduser $user $group

Both these commands do not change the set of groups to which the user already belongs.

  • mentioning which those better and simpler tools are would be helpful. – Sedat Kapanoglu Jul 29 '12 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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