26, Oct 2026 RSS feed ↗

How to Add User to Group on CentOS

Groups on CentOS

On a CentOS system, groups are used to manage user access to system resources. A group is a collection of users that share common access permissions to resources such as files, directories, and devices.

Groups are created and managed with the groupadd, groupmod, and groupdel commands. Each user on the system is a member of at least one group and can be a member of additional groups. By default, a user is a member of the group with the same name as the user's username.

Groups are used to control access to resources through the use of permissions. When you create a file or directory, you can assign permissions to the file or directory that specify which users and groups have access to the resource. For example, you can give read and write permissions to the group developers for a specific directory, allowing all members of the developers group to read and write to the directory.

Groups are also used to manage access to certain system commands and settings. For example, the sudo command allows users in the wheel group to execute commands with root privileges.

How to Add User to Group on CentOS

To add a user to a group on a CentOS system, you can use the usermod command. Here's an example of the basic syntax:

usermod -a -G group_name username

This command will add the user username to the group group_name. The -a option tells usermod to append the user to the group, rather than replacing the user's current group membership.

Here's an example of how to use usermod to add the user john to the group developers:

usermod -a -G developers john

To make the change effective, you may need to log out and log back in or reboot the system.

Alternatively, you can use the gpasswd command to add a user to a group. The syntax for gpasswd is similar to usermod, but you need to specify the group name with the -a option, like this:

gpasswd -a username group_name

For example, to add the user john to the group developers using gpasswd, you would run the following command:

gpasswd -a john developers

Again, you may need to log out and log back in or reboot the system to make the change effective.

E

Evren E.

Evren Elveren is the founder of LinuxHospital, iPhonePost, iPhonePedia, CasinoPost, SongArea, SongLyrics.band and LyricsKid. An entrepreneur active in online publishing and digital projects since 2006, he brings a publisher's perspective to the way technology, entertainment and online businesses develop. His background in architecture informs his interest in design, usability and the small details that make a product or website work well. Evren writes about consumer technology, Linux, digital finance and music, connecting product announcements with their wider business and cultural context. Across the network, his editorial focus is on clear explanations, useful comparisons and practical information that helps readers understand a change before deciding what to do next.

More from this author →