Create Linux Group

The groupadd command used to create new group account. The new group will be entered into the system files as needed. This is System Management command.


groupadd [options] GROUP


Create a group called group Database_group

groupadd Database_group -p Database@123

Unlike user creation, we can assign the password at the time of group creation.

To verify the group created or not.

cat /etc/group | grep Database_group

Create Linux Group

Add user to group Database_group

usermod -G Database_group k2admin

How to check whether user added to group or not

cat /etc/group | grep Database_group


We can find using the id command as shown below

id -Gn k2admin


Option Description
f exit successfully if the group already exists, and cancel -g if the GID is already used
g use GID for the new group
h display this help message and exit
K override /etc/login.defs defaults
o allow to create groups with duplicate(non-unique) GID
use this encrypted password for the new group
r create a system account

The groupadd command exits with the following values:

Option Description
0 success
2 invalid command syntax
3 invalid argument to option
4 GID not unique (when -o not used)
9 group name not unique
10 can´t update group file
Powered by k2schools
Skip to toolbar