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 GID

    Sets the numeric group ID.

  • -r

    Creates a system group, with a GID from the reserved range.

  • -f

    Does not fail if the group already exists; if the GID is taken it picks another.

  • -o

    Allows creating a group with an already used GID (only together with -g).

  • -R DIR

    Applies the changes inside the given root directory (chroot).

Usage examples

  • sudo groupadd devs

    Creates the devs group with the next free GID.

  • sudo groupadd -g 1500 contabilidad

    Creates the contabilidad group with GID 1500.

  • sudo groupadd -r servicio_web

    Creates a system group for a service.

  • getent group devs

    Checks 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.

Related commands