How-To Guides and Blog

How to Manage Groups Account in Linux

NBH Support
No Comments


Managing local group accounts involves creating, modifying, deleting a group and as well as displaying information about a group. You can also perform other operations like adding and removing local users from a group. Linux uses groups to organize users for information sharing and file privacy. Local groups in the Linux system are defined in the /etc/group file. The file shows the information about members of that group, which includes their GID.

Every user belongs to a primary group by default with GID number listed in the /etc/passwd file. Usually, when a user is created, its primary group is the same as the user; with the same name as the user. Every file created by a user is owned by its primary group. A user can have access to other files from a different group as far as he is a member of that group, and permissions are set which do not restrict the user from accessing the files.


Creating a new group is creating a supplementary group. Don’t let that get you confused. In a Linux system, you can be in a primary group and supplementary group. In this section, you will learn how to create a supplementary group. To create a supplementary group, you need the groupadd command. groupadd groupname without an option creates a group and uses the available options in the /etc/login.defs file. The –g option will specify a specific GID to the group

When the –r option is specified while creating a group, it uses the GID defined by the system in the /etc/login.defs file. These are the basic options you will possibly need to create a group. If you deepen your knowledge and you feel like using more options, you can use the groupadd manual page by entering man groupadd on the command line.

We just created a group without any option. The system will assign the group the available GID. You can also specify your options while creating the group


After creating a group, you could choose to change the name or GID of the group. To change the name or GID of a group, you need the groupmod command. The –g option will change the GID of the group and –n option will change the name of the group

We just renamed our group name to accounting by specifying the –n option followed by the new group name and the old group name


The groupdel command deletes a group by removing all the entries that refer to that group. A group may not be deleted if it’s a primary group of an existing user. To go about this, you have to use the userdel command to delete the user which will, in turn, delete its primary group

Unlike creating a group, there is no exclusive option while deleting a group. The syntax goes as groupdel groupname

We just deleted the recently created group from the system using the groupdel command. You can view the groups in the system from the /etc/group


Adding a user to a supplementary group means adding a user to a group outside its primary group. The membership of a group can be altered by using the usermod command. The usermod command can change the user’s primary group by appending –G option and as well add a user to a supplementary group by appending –a to the –G option.

Please note that, while adding a user to a supplementary group, you must use the –a option (append) to add to the user to another group. If you try using the –g option only, the user will be removed from every other group.

The command for changing a users primary group is usermod –g groupname while that of adding to a supplementary group is usermod –aG groupname:username


Groups information is stored in the /etc/group files. They are various ways in which you can view the members of a group. You can use cat, member, or getent command. Each of this method can be demonstrated on the command line.


As a beginner venturing into Linux, this article will give you an in-depth understanding of how to create, delete, and modify a group. Also, keep in mind that the purpose of groups in Linux is for easy accessibility of files among users. When you see a group in Linux, reflect that to a WhatsApp group where multiple users get to share and receive files or information at the same time.

Keep reading these articles; we will also be discussing file permissions. This a knowledge you need to have while sharing files among users