Saturday, 2 May 2009

Tip of the Day: Add an Existing User to an Existing Group

For this task we'll use the usermod command. From the manual page, modifies a user account. In the following example we add the user embryo to the group vboxusers (you have to be root in order to use usermod):

usermod -a -G vboxusers embryo

Notice that you can also add the user to several groups in one command:

usermod -a -G group0 group1 group2 embryo

Which will add user embryo to groups group0, group1 and group2.

The -a switch is used only with -G and means 'append the user to supplemental groups'. The -G switch specifies a list of supplemental groups to add the user to.

No comments: