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

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

# 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.
Example:

[[email protected] ~]# groupadd -g 666 megrp 
[[email protected] ~]# grep -w megrp /etc/group
megrp:x:666:

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.
Example:

[[email protected] ~]# groupadd -o -g 666 megrp2 
[[email protected] ~]# grep megrp /etc/group
megrp:x:666:
megrp2:x:666:

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,

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

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. 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 *