Jump to content

How to Add Users to a Group in Fedora Linux

Linux Hint

Recommended Posts

This guide showcases how to add a user to a user group or more in Fedora Linux.


To perform the steps that are demonstrated in this guide, you need the following components:

User Groups in Fedora Linux

Linux is a robust multi-user system that allows multiple users to access and use the system simultaneously. Each user is assigned a set of permissions which limits what the user can and can’t do on the system.

However, defining the user permissions on a per-user basis can be daunting. To simplify this, Linux comes with the user groups feature. A user group, as the name suggests, comprises of multiple users. We can specify the permissions for the user group that are applied to all users within that group.

Types of User Groups

1. Primary User Groups

Each user in the system belongs to exactly one primary user group. The group name is the same as the target user.

Whenever the user creates a file, the primary group is assigned to the file permissions.

For example, the “viktor” user belongs to the “viktor” primary user group:

$ groups viktor


Let’s test the file permission assignment. The following command creates an empty file and lists its file permissions:

$ touch test && ls -l test


2. Secondary or Supplementary Groups

These groups are generally used to manage a certain permission to a set of users. Any user can be a part of zero or more secondary user groups.

Here are some of the common secondary user groups that you will come across:

  • wheel: It’s a user group that exists in all modern UNIX/Linux systems. It’s used to control the access to a root privilege. Any user within this group can run the commands with sudo.
  • nobody: A user group that has no privilege.
  • root: It comes with complete system admin control.
  • lp: It controls the access to parallel port devices.
  • proc: This group permits the access to learn the process info. Otherwise, it is prohibited by the proc file system.

Besides these common groups, there are also other user groups:

  • audio: Sound hardware
  • video: Video capture devices, 2D/3D acceleration devices, and such
  • kvm: Access to KVM virtual machines
  • disk: Access to block devices
  • floppy: Access to floppy drives
  • optical: Access to CD/DVD drives
  • storage: Access to removable drives

Various programs also create their own users and groups. For example: postgres (PostgreSQL), mysql (MySQL), etc.

Listing the User Groups

There are multiple ways to list all the groups in the system. To find the groups that a user is part of, use the following groups command:

$ groups <user>


To list all the groups that are present in the system, we can check the content of the /etc/group file:

$ cat /etc/group


The “getent” command can also list all the groups in a similar fashion:

$ getent group


To get a list of only the group names, we can edit the output using “awk”:

$ getent group | awk -F: '{ print $1}'


Adding a User to a Group

In this section, we will demonstrate how to add a user to an existing group.

Creating a New User

For demonstration, we create a new dummy user. However, the procedure is still valid for any existing user.

To create a new user, run the following command:

$ sudo useradd dummy


If you want to create the user with its own home directory, use the following command instead:

$ sudo useradd -m dummy


Next, assign a login password for the new user:

$ sudo passwd dummy


Adding a User to a User Group

By default, the user belongs to its own primary user group:

$ groups dummy


To add the user to a secondary user group, use the “usermod” command:

$ sudo usermod -aG <group> <username>


If you want to add the user to multiple groups, use the following command instead:

$ sudo usermod -aG <group_1>,<group_2>,<group_3> <username>



Use the “groups” command to check the list of groups that the user is part of:

$ groups dummy


Bonus: Removing a User from a Group

If a user is to be revoked with the permissions granted by a user group, we can simply remove the user from the group.

To remove a user from a group, use the following command:

$ sudo gpasswd -d <username> <group>


We can verify if it worked using the “groups” command:

$ groups <username>



We demonstrated the various ways of adding a user to a user group in Fedora Linux. In addition, we also showcased how to list all the groups in the system and how to remove the users from a user group.

Interested in learning more about user management? Check out this guide on adding users to sudoers. The Fedora sub-category also contains plenty of guides on various aspects of Fedora Linux.

Happy computing!

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...