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'm using Ubuntu 11.10 and I installed VirtualBox.

This required me to add myself to the vboxusers group but when I add myself to vboxusers group I am no longer be in other groups and especially admins group!

When I add myself back to admins group I no longer be am in the vboxusers group !

Commands that I used

  • to add user to "vboxusers": usermod -G vboxusers myusername

  • to add user back to admins group in single user mod: usermod -aG admin myusername

share|improve this question
    
@Caesium Thank u. Thanks all :) Solved by following Caesium's solution :D –  R9TySix Feb 15 '12 at 17:05
    
Then you should fix the accepted answer, currently a non-working solution is accepted which will confuse future visitors. –  Caesium Feb 15 '12 at 17:31

6 Answers 6

up vote 17 down vote accepted

Your second command is right.

By default, usermod -G replaces all supplementary groups the user is in (the primary group is generally named the same as your username, and specified separately; don't mess with that though). By also using -a it appends the groups you give.

So this should work (and does, for me, just tried it):

usermod -aG vboxusers myusername

If running that command takes you out of any other group then you've found a bug. Note you have to relogin to see the effects.

share|improve this answer

Alternatively:

gpasswd --add myusername vboxusers
share|improve this answer

According to the usermod man page the correct command to add a user to a group is

sudo usermod -G group -a username

or in your case since you want to add your self to the vboxusers group that will be

sudo usermod -G vboxusers -a $USER
share|improve this answer
    
Exactly equivalent to -aG group (assuming usermod knows how to parse args) –  Caesium Feb 15 '12 at 16:56

Never use the top method to add a user to vboxusers by using the usermod -G vboxusers myusername command. This will make you lose your sudo privileges!

If you have lost your sudo privileges, you can use the method described here to recover them. It boils down to executing the following command:

usermod -G adm,cdrom,sudo,dip,plugdev,lpadmin,guoshicheng,vboxusers myusername
share|improve this answer
1  
Welcome to Ask Ubuntu! The question's author already used the command you're telling him not to use. He has also already accepted a solution for his problem. There is actually no point in anwering the question again. And linking to a site in Chinese is also not very helpful on an English site. –  bender Jan 23 '13 at 23:45
    
@bender Actually there is a point if the answer is valid and on topic. Accepting answer means that it worked for the OP. Please read the about page. –  Symin Jan 24 '13 at 0:17
    
@Symin: Nevertheless, the question's author already used this command. Strictly seen, this is already not an answer to the question. The accepted answer already describes in detail what has been done wrong and why, this answer adds (almost) no new information. And describing (once again) how to get back lost privileges has been done many many many times on this site. And just for the sake of completeness, this command won't work any more after sudo privileges were lost (unless one hasn't logged off yet or still has an open root shell). –  bender Jan 24 '13 at 0:49

What you want to do is just open the terminal and vi /etc/group then add of replace vboxusers:x:128:uname (uname of the account), save and log out. Just login and open VirtualBox, Settings -> USB -> Add filter from device. I think it will work.

share|improve this answer

To add a user to multiple groups use the following command is executed with commas seperating each group for example: admin,vboxusers

useradd -G admin,vboxusers myusername

share|improve this answer
    
That will add a new user and make the user belong only to those groups. –  Bruno Pereira Feb 15 '12 at 16:35
2  
If that's so, then Oli's answer is wrong too? –  Caesium Feb 15 '12 at 16:52

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.