(no commit message)
[ikiwiki.git] / docs / handbook / handbook-users-groups.mdwn
1 \r
2 \r
3 ## 8.9 Groups \r
4 \r
5 A group is simply a list of users. Groups are identified by their group name and GID (Group ID). In DragonFly (and most other UNIX® like systems), the two factors the kernel uses to decide whether a process is allowed to do something is its user ID and list of groups it belongs to. Unlike a user ID, a process has a list of groups associated with it. You may hear some things refer to the ***group ID*** of a user or process; most of the time, this just means the first group in the list.\r
6 \r
7 The group name to group ID map is in `/etc/group`. This is a plain text file with four colon-delimited fields. The first field is the group name, the second is the encrypted password, the third the group ID, and the fourth the comma-delimited list of members. It can safely be edited by hand (assuming, of course, that you do not make any syntax errors!). For a more complete description of the syntax, see the [group(5)](http://leaf.dragonflybsd.org/cgi/web-man?command#group&section5) manual page.\r
8 \r
9 If you do not want to edit `/etc/group` manually, you can use the [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&section8) command to add and edit groups. For example, to add a group called `teamtwo` and then confirm that it exists you can use:\r
10 \r
11  **Example 8-7. Adding a Group Using pw(8)** \r
12 \r
13     \r
14     # pw groupadd teamtwo\r
15     # pw groupshow teamtwo\r
16     teamtwo:*:1100:\r
17 \r
18 \r
19 The number `1100` above is the group ID of the group `teamtwo`. Right now, `teamtwo` has no members, and is thus rather useless. Let's change that by inviting `jru` to the `teamtwo` group.\r
20 \r
21  **Example 8-8. Adding Somebody to a Group Using pw(8)** \r
22 \r
23     \r
24     # pw groupmod teamtwo -M jru\r
25     # pw groupshow teamtwo\r
26     teamtwo:*:1100:jru\r
27 \r
28 \r
29 The argument to the `-M` option is a comma-delimited list of users who are members of the group. From the preceding sections, we know that the password file also contains a group for each user. The latter (the user) is automatically added to the group list by the system; the user will not show up as a member when using the `groupshow` command to [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&section8), but will show up when the information is queried via [id(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=id&section=1) or similar tool. In other words, [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=pw&section=8) only manipulates the `/etc/group` file; it will never attempt to read additionally data from `/etc/passwd`.\r
30 \r
31  **Example 8-9. Using id(1) to Determine Group Membership** \r
32 \r
33     \r
34     % id jru\r
35     uid#1001(jru) gid1001(jru) groups=1001(jru), 1100(teamtwo)\r
36 \r
37 \r
38 As you can see, `jru` is a member of the groups `jru` and `teamtwo`.\r
39 \r
40 For more information about [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&section8), see its manual page, and for more information on the format of `/etc/group`, consult the [group(5)](http://leaf.dragonflybsd.org/cgi/web-man?command=group&section=5) manual page.\r
41 \r
42 \r
43 \r
44 CategoryHandbook\r
45 CategoryHandbook-usermanagement\r