Wednesday, April 17, 2013

Groupadd command is used to create a new group account using the
specified values with options or default values from the system. All
information related to the group added into the system files as needed. There
are many options present in group add command to change account settings of
group.

We will understand all major options of groupadd command with examples:

How to create new group ?

Suppose, we want to create a new group and but we are not sure given
group ID is used somewhere or not. So, in this case we can use –f option with
–g option to create group forcefully. i.e. if gid is already used then it will
take new gid and create the group.

As below example, 1010 gid is used already but due to –f option,
command executes and it has taken next group ID i.e. 1011.

root@rhel:~#
cat /etc/group | grep test

test1:x:1010:

root@rhel:~#
groupadd -fg 1010 login

root@rhel:~#
cat /etc/group

login:x:1011:

How to create system group?

We can create system group with –r option with groupadd command. The
numeric id of system groups always chosen in the SYS_GID_MIN-SYS_GID_MAX range,
which is defined in login.defs
instead of GID_MIN-GID_MAX