Creating a user group and adding members to it
So far, I’ve been doing all of the demos inside my own home directory, just for the sake of showing the basic concepts. But the eventual goal is to show you how to use this knowledge to do something more practical, such as controlling file access in shared directories.
Let’s say that we want to create a marketing
group for members of—you guessed it—the marketing department:
[donnie@localhost ~]$ sudo groupadd marketing
[sudo] password for donnie:
[donnie@localhost ~]$
Let’s now add some members. We can do that in three different ways:
- Add members as we create their user accounts.
- Use
usermod
to add members that already have user accounts. - Edit the
/etc/group
file.
Adding members as we create their user accounts
First, we can add members to the group as we create their user accounts, using the -G
option of useradd
. On Red Hat, AlmaLinux, or CentOS, the...