Managing User Groups
Shell·3 min read·Jan 1, 2025
In Unix-like operating systems, a group is a collection of users with similar permissions.
Groups can have multiple users as members, and users can belong to multiple groups simultaneously.
Like users, each group has a unique name and a unique identifier.
Creating a new group
To create a new group, you can use the groupadd command as follows:
$ sudo groupadd groupnameWhere groupname is the name of the group you want to create.
Example
This command will create a new group named developers:
$ sudo groupadd developersListing existing groups
In Unix-like operating systems, every group on the system is listed in the /etc/group file, which is a text-database used for managing user accounts and group memberships.
To display this file, you can use the cat command as follows:
$ cat /etc/groupThe /etc/group file format
Each line of the /etc/group file defines a group and consists of 4 fields separated by colon characters (:):
Unlock the CLI & Scripting with Bash module
Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.
You get immediate access to:
- 34 focused lessons across the CLI and Bash
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle