groupadd
Linux · Users and permissions · reference only
What it does
Creates a new group on the system. You can set the GID by hand or let the next free one be assigned.
Syntax
groupadd [opciones] grupo
Options and parameters
-g GIDSets the numeric group ID.
-rCreates a system group, with a GID from the reserved range.
-fDoes not fail if the group already exists; if the GID is taken it picks another.
-oAllows creating a group with an already used GID (only together with -g).
-R DIRApplies the changes inside the given root directory (chroot).
Usage examples
sudo groupadd devsCreates the devs group with the next free GID.
sudo groupadd -g 1500 contabilidadCreates the contabilidad group with GID 1500.
sudo groupadd -r servicio_webCreates a system group for a service.
getent group devsChecks the group was created and shows its GID and members.
Notes and common mistakes
- On Debian and Ubuntu, GIDs below 1000 are reserved for the system.
- -o allows duplicate GIDs, but it is rarely a good idea.