0% found this document useful (0 votes)
14 views2 pages

Notes 5

The document provides instructions for adding a user to a group in Rocky Linux 9. It explains that groups help organize user access rights and resources. It then outlines the steps to create a new group with "groupadd" or add a user to an existing group with "usermod". It also presents the "gpasswd" command as an alternative to manage group passwords and memberships.

Uploaded by

TovaAAnto RRdlfr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Notes 5

The document provides instructions for adding a user to a group in Rocky Linux 9. It explains that groups help organize user access rights and resources. It then outlines the steps to create a new group with "groupadd" or add a user to an existing group with "usermod". It also presents the "gpasswd" command as an alternative to manage group passwords and memberships.

Uploaded by

TovaAAnto RRdlfr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Home

Learning
Videos
Subscribe

Linux Commands
How to Add a User to a Group in Rocky Linux 9
4 days ago
by Prateek Jangid
Groups are used to organize the users to define their access rights in the system.
Adding a user to a group helps you share the resources (files and services) and
offers a streamlined approach to managing the users.

As an administrator, adding a user to the group is also beneficial to maintain


security. However, if you are unfamiliar with how to add users to a group, we
recommend you to read this guide completely. In this guide, we will explain the
simple methods to add the users to a group in Rocky Linux 9 (RHEL-based OS).
How to Add a User to a Group in Rocky Linux 9

In Rocky Linux, there are multiple ways to add the users to a group. But if you
want to create a group first, run the following command:
sudo groupadd group

Make sure that you replace the “group” with the name that you want to use. For
example, we create a group named “LinuxTeam”:
sudo groupadd LinuxTeam

If you want to list all the available groups in the system, you can run the
following command:
getent

As you can see in the previous image, there are 5 groups: LinuxTeam,
LinuxTeam_Devs, LinuxTeam_Managers, LinuxTeam_Interns, and LinuxTeam_SEO. If you
want to get a simplified result, execute this command:
getent group | cut -d: -f1

Now, we have multiple users in the system. Let’s list them all through the
following command:
getent

or
getent group | cut -d: -f1

If you want to add a user to a group, run the following command:


sudo usermod -a -G LinuxTeam Mackle

In the previous command, the -a option ensures that the users must be added to a
group without removing them from the existing one.

Similarly, you can use the “gpasswd” command to manage the groups’ passwords and
memberships. Here is the example command that you can try:
sudo gpasswd -a Ron LinuxTeam_SEO

If you want to add a single user in multiple groups, you can run the following
command:

sudo usermod -a -G <group1>,<group2>,<group3> <username>


Remove a User from a Group

If you want to remove a user from a group, run the following command:
sudo gpasswd -d <username> <group_name>

Conclusion

This tutorial is all about adding a user to a group in Rocky Linux 9. This guide
works like a complete information to understand everything about adding and
removing groups in Linux. Remember to use the previous commands correctly.
Otherwise, you may get errors while adding users to groups.
About the author
Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring
what is new in the world of Linux and sharing with my readers.
View all posts
RELATED LINUX HINT POSTS

How to Add a User to a Group in Rocky Linux 9


How to Add a Directory to the Path on Rocky Linux 9
How to Prevent the SSH Broken Pipe Error
15 Rsync Examples
How to SSH from the Linux Command Line
How to Install Alpine Linux on a VMware Workstation 17 Pro Virtual Machine
Linux IP Command

Linux Hint LLC, [email protected]


1309 S Mary Ave Suite 210, Sunnyvale, CA 94087
Privacy Policy and Terms of Use

You might also like