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.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
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.

share|improve this answer
    
mentioning which those better and simpler tools are would be helpful. –  ssg Jul 29 '12 at 14:11
    
@ssg: thank you, done. –  enzotib Jul 29 '12 at 14:16
    
great job, thanks! –  ssg Jul 29 '12 at 14:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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