LinuxCommandLibrary

group

System group database file

TLDR

View group file
$ cat /etc/group
copy
Find groups for user
$ groups [username]
copy
Find group by name
$ getent group [groupname]
copy
List group members
$ getent group [groupname] | cut -d: -f4
copy

DESCRIPTION

/etc/group is the system file that defines groups and their members. Each line contains a group entry with four colon-separated fields: group name, password placeholder, numeric GID, and a comma-separated list of member usernames.
Groups control file access permissions and are fundamental to Unix security. Users can belong to multiple groups, with one primary group set in /etc/passwd.

FILE FORMAT

$ groupname:password:GID:members
copy
Fields:
- groupname: Group name
- password: Usually 'x' (see /etc/gshadow)
- GID: Numeric group ID
- members: Comma-separated list of users

RELATED COMMANDS

$ groupadd groupname      # Create group
groupdel groupname      # Delete group
groupmod -n new old     # Rename group
gpasswd -a user group   # Add user to group
gpasswd -d user group   # Remove user from group
newgrp groupname        # Switch primary group
copy

CAVEATS

Direct editing not recommended; use groupadd/groupmod. Changes may require logout to take effect. GIDs below 1000 typically reserved for system groups.

SEE ALSO

groups(1), groupadd(8), groupmod(8), passwd(5)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard