When I add myself "vboxusers" group I an no longer in the "admins" group
Solution 1
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.
Solution 2
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
Solution 3
Alternatively:
gpasswd --add myusername vboxusers
Solution 4
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
keram
Updated on September 18, 2022Comments
-
keram over 1 year
Code:
digits.each do |digit| puts digit.content #&0000000000032056.00000032 056 value = digit.content[24..-1].strip puts value #32 056 it's ok puts value.gsub(/\s+/, "") #32 056 !!!! I expected 32056 population << value end
I don't understand why gsub does not work as I expected :/ Could somebody help?
[EDIT]
Anyway I do it another way:
value = digit.content.split(".")[0] value = value[12..-1].strip
but I am still wonder, why first solution sucks.
-
R9TySix about 12 years@Caesium Thank u. Thanks all :) Solved by following Caesium's solution :D
-
Caesium about 12 yearsThen you should fix the accepted answer, currently a non-working solution is accepted which will confuse future visitors.
-
-
Bruno Pereira about 12 yearsThat will add a new user and make the user belong only to those groups.
-
Caesium about 12 yearsIf that's so, then Oli's answer is wrong too?
-
Caesium about 12 yearsExactly equivalent to
-aG group
(assuming usermod knows how to parse args) -
keram about 12 yearsputs value.class gives me String :/, puts digit.content.class is String too. Maybe wikipedia has some kind of parsing protection? I try to parse: pl.wikipedia.org/wiki/Miasta_w_Polsce_(statystyki) (5th column values)
-
keram about 12 yearsOoops I totally forget about Thanks.
-
bender over 11 yearsWelcome 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.
-
Symin over 11 years@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.
-
bender over 11 years@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).
-
Edward Torvalds over 9 yearsi am getting error:
usermod: group 'vboxusers' does not exist