Ubuntu Linux: Add a User To Group

Create a group called foo and add user tom to a secondary group called foo:
$ sudo groupadd foo
$ sudo useradd -G foo tom

OR
# groupadd foo
# useradd -G foo tom

Verify new settings:

id tom
groups tom

Finally, set the password for tom user, enter:
$ sudo passwd tom
OR
# passwd tom
You can add user tom to multiple groups – foo, bar, and ftp, enter:
# useradd -G foo,bar,ftp tom

Ubuntu Linux: add a existing user to existing group

To add an existing user jerry to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:

usermod -a -G ftp jerry
id jerry

To change existing jerry’s primary group to www, enter:

usermod -g www jerry

 

Leave a Comment