How to create a new user group in Linux

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM


$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM


$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

In the Linux operating system, user management plays a crucial role in maintaining system security and organization. One powerful aspect of user management is the ability to create and manage user groups. User groups allow administrators to assign common permissions and access levels to a set of users. In this article, we will explore how to create a new user group in Linux with practical command examples.

Step 1: Open the Terminal

Before we begin, open a terminal on your Linux system. You can usually find it in your system’s applications menu or by using the keyboard shortcut Ctrl + Alt + T.

Step 2: Check Existing Groups

Before creating a new user group, it’s a good practice to check the existing groups on your system. The cat command combined with the /etc/group file provides a comprehensive list.

cat /etc/group

This command will display a list of groups on your system, giving you an overview of the available groups and their corresponding group IDs.

Step 3: Create a New Group

To create a new user group, you can use the groupadd command followed by the desired group name. In this example, we’ll create a group named “examplegroup.”

sudo groupadd examplegroup

The sudo command is used to execute the groupadd command with administrative privileges.

Step 4: Verify Group Creation

To ensure that the new group has been successfully created, you can again check the contents of the /etc/group file using the cat command.

cat /etc/group

Look for the entry corresponding to the group you just created (“examplegroup” in this case) to confirm its existence.

Step 5: Add Users to the Group

Now that the group is created, you may want to add users to it. The usermod command, combined with the -aG option, allows you to add users to a specific group.

sudo usermod -aG examplegroup username

Replace “username” with the actual username of the user you want to add to the group.

Step 6: Verify User Group Membership

To verify that a user has been successfully added to the newly created group, you can use the id command followed by the username.

id username

This command displays information about the specified user, including group memberships. Ensure that the “examplegroup” is listed among the user’s groups.

Step 7: Modifying Group Properties

If you need to modify the properties of an existing group, such as its name or Group ID (GID), you can use the groupmod command. For example, to change the group name from “examplegroup” to “newgroup,” use the following command:

sudo groupmod -n newgroup examplegroup

Step 8: Deleting a Group

To remove a group from the system, you can use the groupdel command. Ensure that no users are associated with the group before attempting to delete it.

sudo groupdel examplegroup

Step 9: Setting Group Password

Groups can have passwords in Linux, although it’s not mandatory. If you want to assign a password to a group, you can use the gpasswd command:

sudo gpasswd examplegroup

Follow the prompts to set a password for the group.

Step 10: Adding Permissions to a Group

In Linux, file and directory permissions are crucial for controlling access to resources. Let’s explore how to add specific permissions to a user group using the chmod command.

Identify the File or Directory

Begin by identifying the file or directory for which you want to grant additional permissions to the group. For example, let’s assume you have a directory named “shared_directory.”

View Current Permissions

Use the ls command with the -l option to view the current permissions of the file or directory. This will display detailed information, including the permissions, owner, group, and other details.

ls -l shared_directory

Add Permissions to the Group

To add permissions to the group, you can use the chmod command along with the symbolic representation of permissions. For instance, to grant read and write permissions to the group, you can use:

sudo chmod g+rw shared_directory

This command adds read and write permissions (+rw) to the group (g) for the specified file or directory.

Verify Permissions

After adding the permissions, use the ls -l command again to verify that the changes have been applied.

ls -l shared_directory

Ensure that the group permissions now include the desired read and write permissions.

Recursive Permissions (Optional)

If you want to apply the same permissions recursively to all files and subdirectories within the specified directory, you can use the -R option with chmod. For example:

sudo chmod -R g+rw shared_directory

This recursively adds read and write permissions to the group for all files and subdirectories within “shared_directory.”

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.