Knowledge Base:Adding a user to a group

From Gentoo Wiki
Jump to: navigation, search

Synopsis

This article describes how to add a Linux user (account) to a group.

Environment

Any Gentoo Linux environment not using a centralized account management tool (like LDAP).

root #grep ^group /etc/nsswitch.conf
group:   compat

Analysis

Unless defined otherwise, groups and group membership are managed through the /etc/group file. Some systems have accounts managed through a centralized resource (such as an LDAP directory). The /etc/nsswitch.conf file defines where the system looks for group membership.

When using a centralized user repository, the resolution given below might not work.

Resolution

Although you can directly edit /etc/group, it is much easier (and less error prone) to use the gpasswd command.

For instance, to add the user "larry" to the wheel group:

root #gpasswd -a larry wheel