The groupadd command’s switches with example – Unix/Linux

The “gropadd” is used to create a new group under Linux.

# groupadd [options] GROUPNAME

Switches with example:

1, -f, –force
This option causes the command to simply exit with success status if the specified group already exists. When used with -g, and the specified GID already exists, another (unique) GID is chosen (i.e. -g is turned off).

2, -g, –gid GID

The numerical value of the group´s ID. This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater than 999 and greater than every other group. Values between 0 and 999 are typically reserved for system accounts.

[root@localhost ~]# groupadd -g 666 megrp 
[root@localhost ~]# grep -w megrp /etc/group

3, -h, –help
Display help message and exit.

4, -K, –key KEY=VALUE
Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple -K options can be specified.
Example: -K GID_MIN=100 -K GID_MAX=499
Note: -K GID_MIN=10,GID_MAX=499 doesn´t work yet.

5, -o, –non-unique

This option permits to add a group with a non-unique GID.

[root@localhost ~]# groupadd -o -g 666 megrp2 
[root@localhost ~]# grep megrp /etc/group

6, -p, –password PASSWORD

The encrypted password, as returned by crypt(3). The default is to disable the password.
Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes. You should make sure the password respects the system´s password policy.

7, -r, –system

Create a system group.
The numeric identifiers of new system groups are choosen in the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs, instead of GID_MIN-GID_MAX.

That’s it!! 🙂

Also refer:
groupdel, groupmems, groupmod,

ls, head, tail, top, ps, find, crontab

Arunlal Ashok

Sr. Linux Server Administrator. I'm managing Linux servers since 2012. I started this blog to share and discuss my ideas. Check My Profile in uPwork (oDesk) and create a job, if you need any administration help. Thanks!!

You may also like...

1 Response

  1. February 1, 2014

    […] Links : groupadd , groupmems, […]

Leave a Reply

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