Linux Redhat

Linux Add User To Group

You can use the useradd or usermod commands to add a user to a group. The useradd command creates a new user or update default new user information. The usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.

useradd Example – Add A New User To Secondary Group

You need to the useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. The syntax is as follows:

#useradd -G {group-name} username

Add a new user to primary group

#useradd -g oinstall oracle

Add a existing user to existing group

#usermod -a -G osm oracle

Change existing user tony primary group to dba
#usermod -g dba oracle

Leave a Reply

Your email address will not be published. Required fields are marked *