How to Use the groupadd Command in Linux to Create New User Groups

Managing file permissions across multiple users on a Linux system is virtually impossible if you assign access rights individually. Instead, the Linux security model relies on “Groups.” By clustering users into specific groups (such as “developers” or “accounting”), you can assign directory permissions to the entire group at once. The fundamental tool for creating these administrative clusters is the groupadd command.

Why Use the groupadd Command?

The groupadd utility is a low-level command-line tool that modifies the system’s /etc/group file safely. When you use this command, the system automatically allocates a unique Group ID (GID) and registers the new group, making it immediately available for use in file ownership commands (like chown) or user modification commands (like usermod).

Step 1: Create a Basic Group

Creating a new group requires root privileges, so you must use sudo.

  1. Open your Linux terminal.
  2. To create a new group named “developers”, use the following syntax:
sudo groupadd developers

The command will execute silently. If it returns to the prompt without an error, the group was created successfully. By default, the system will automatically assign the next available GID (typically a number above 1000).

Step 2: Assign a Specific GID

In enterprise environments, you may need a group’s GID to match across multiple servers for NFS (Network File System) compatibility. You can force a specific GID using the -g flag.

  1. To create a group named “accounting” with a specific GID of 5050, type:
sudo groupadd -g 5050 accounting

If the GID 5050 is already taken by another group, the command will return an error and fail.

Step 3: Verify the Group Creation

Because groupadd does not provide visual confirmation, you should verify the group exists in the system database.

  1. You can search the /etc/group file using the grep command:
grep "developers" /etc/group

The output will display the group name, the group password placeholder (x), and the assigned GID, formatted like this: developers:x:1001:.

Step 4: Add Users to the New Group

Once the group exists, you must use a separate command to actually add users to it.

  1. To append a user named “john” to the “developers” group, use the usermod command with the append (-a) and group (-G) flags:
sudo usermod -aG developers john

By mastering the groupadd command, system administrators can build organized, secure access control structures before deploying shared directories on a Linux server.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.