NAMEThe options in synopsis means:
groupadd - create a new group
SYNOPSIS
groupadd [-g GID [-o]] [-f] [-K KEY=VALUE] group
DESCRIPTION
The groupadd command creates a new group account using the values
specified on the command line plus the default values from the system.
The new group will be entered into the system files as needed.
- -g GID means we can provide a group id to the new group. However the group id must be greater than 999 and hasn't been used by existing group.
- -o permits to add a group with a non-unique GID.
- -f will turn off -g group id you specified if it's already been used by the existing group. If the name of the new group you specified already exist, it will exit with success status.
- -K KEY=VALUE overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others).
groupadd new_group_name
Here is an example of Ubuntu create group using groupadd command:
All Ubuntu groups were kept in one file. The location of the file is in /etc/group. We can view groups in Ubuntu using cat, less, more or text editor. Here is an example of Ubuntu /etc/group file:
luzar@ubuntu:~$ sudo groupadd itdept
[sudo] password for luzar:
luzar@ubuntu:~$
luzar@ubuntu:~$ sudo less /etc/groupSee the itdept group that we created just now? We didn't specify a gid, so Ubuntu assigns a next gid from the existing groups.
root:x:0:
daemon:x:1:
bin:x:2:
...
...
...
jimi:x:1002:
alex:x:1003:
itdept:x:1004: