How do I add multiple user to UNIX group?

In Linux, I can create a group:

sudo groupadd mygroup

and add several users to it:

sudo usermod -a -G mygroup userA
sudo usermod -a -G mygroup userB
sudo usermod -a -G mygroup userC

Or, if gpasswd is available (should be on most distributions except e.g. Solaris) you can provide a comma separated list of users followed by the group name:

gpasswd -M userA,userB,userC mygroup

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.