Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
Groups give the same rights to many users, for example write access to a shared folder. The groups are in /etc/group and /etc/gshadow. The GID comes from the range in /etc/login.defs (GID_MIN … GID_MAX) unless you give one.
groupmod renames a group or changes its GID. groupdel removes a group, but not if it is the primary group of a user.
Add members with usermod -aG GROUP USER or gpasswd -a USER GROUP.
Zo schrijf je het
groupadd [OPTION]... GROUP
groupmod [OPTION]... GROUP
groupdel [OPTION]... GROUPOpties 17
Meest gebruikt
groupadd
groupmod
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Create a group
groupadd webadminsGets the next free GID.
2Create a group with a fixed GID
groupadd -g 3000 salesSame GID on all servers for NFS shares.
3Create a system group for a service
groupadd -r appsvcGID under 1000.
4Create a group with members
groupadd -U anna,bob projectxNewer versions only; else use gpasswd -a.
5Rename a group
groupmod -n web-admins webadminsMembers and files keep working: they use the GID.
6Change the GID and fix the files
groupmod -g 3100 sales find / -xdev -gid 3000 -exec chgrp -h sales {} +Files still have the old number until you change them.
7Delete a group
groupdel projectxFails if it is the primary group of a user.
8Set up a shared team folder
2 = setgid: new files get the group sales (see the permissions chapter).
9Do not fail when the group exists (scripts)
groupadd -f salesSafe to run twice, for example in Ansible-like scripts.
10Check the group
getent group sales sales:x:3000:anna,bobName, password placeholder, GID, members.
11Find groups with no members (cleanup)
awk -F: '$4 == "" && $3 >= 1000 {print $1}' /etc/groupPrivate groups of users are listed too; they are normal.
Niets past bij dit filter.
Let op
- groupdel does not change files: they then show the old GID number.
- A user gets new groups only after a new login.
Bestanden
/etc/group, /etc/gshadow- The group data.
/etc/login.defs- GID_MIN, GID_MAX, SYS_GID_MIN, SYS_GID_MAX.
Exitcodes
0 | Done. |
2 | Wrong syntax. |
3 | Wrong value for an option. |
4 | The GID is used already. |
6 | The group does not exist (groupmod, groupdel). |
8 | Cannot delete the primary group of a user (groupdel). |
9 | The group name is used already. |
10 | Could not update the group file. |