All files in Linux are owned by either a user and a group. You can see which user and group own a file using ls -l
.
Groups are very useful for access control. Giving a group ownership over a file makes all its members owners of that file.
Just as you have /etc/passwd
for user management, you have /etc/group
for group management. Similar to how new human users get UIDs from 1000 onwards, human groups get group IDS (GID) from 1000 onwards too. GIDs lower than 1000 are usually intended for system users as opposed to human users.
Commands to know about:
groups
— what groups you’re a member of.groups $USERNAME
for groups a specific user is in.
groupadd
- Analogous to
useradd
in user management.
- Analogous to
groupdel
- Analogous to
userdell
user management.
- Analogous to
usermod --append --groups $GROUP
— add user to a group.