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 a shared group directory. The first step is to create a user group and to add members to it.
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. You 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 or CentOS, the command would look like this:
[donnie@localhost...