Groups
groupadd makes a new group. A group is a named set of accounts.
Make a new group
groupadd devs makes a group named devs. It prints nothing.
$ groupadd devsAdd sam to the group
usermod -aG devs sam adds sam to devs. It prints nothing.
$ usermod -aG devs samCheck the numbers
id sam prints the numbers for sam. The devs number now sits in the list.
$ id samCheck the names
groups sam prints the group names for sam. The list now holds sam and devs.
$ groups samExample
$ id sam
$ groups samKey points
- Use groupadd with a name to make a new group.
- groupadd prints nothing when it works.
- Use usermod -aG devs sam to add sam to the group devs.
- usermod prints nothing when it works.
- Use id with a name to see the groups of that account.
- Use groups with a name to print the group names of that account.
- In short, groupadd makes the group, and usermod puts an account in it.
In this example, id prints the numbers for sam. The list holds two groups now: sam and devs. groups prints the names next. The names are sam and devs.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does groupadd devs do?