GROUPADD(8)

๐Ÿ‘‘ GROUPADD(8) โ€” System Management Commands ๐Ÿ‘‘

okay bestie, gather round, because we're talking about groupadd from the groupadd(8) manual page โ€” the Shadow utils baddie that makes brand new group accounts and honestly? she's iconic. โœจ


๐ŸŒธ NAME ๐ŸŒธ

groupadd โ€” create a new group ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

groupadd [OPTIONS] NEWGROUP

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so basically, groupadd makes a whole new group account. it takes the values you typed on the command line, mixes them with the default values chillin' in your system, and boom โ€” new group. the new group gets entered into the system files as needed, no cap. ๐Ÿซถ

now, groupname rules, and you WILL respect them:

  • only lower and upper case letters, digits, underscores, dashes, or dots. that's it.
  • they can end with a dollar sign ๐Ÿ’ธ
  • dashes are NOT allowed at the beginning of the groupname (front-row seats are taken, sorry)
  • fully numeric groupnames? no. groupnames that are just . or ..? absolutely not.
  • and groupnames may only be up to 32 characters long. that's the ceiling, bestie.

โœจ OPTIONS โœจ

the options that apply to groupadd are giving main character energy:

  • -f, --force โ€” makes the command just... exit with success status if the group you asked for already exists. chill behavior honestly. when it's used with -g and the GID you named already exists, a different (unique) GID gets chosen instead โ€” i.e. -g gets turned off. ๐Ÿšซ
  • -g, --gid GID โ€” the numerical value of the group's ID. this GID must be unique unless you're using the -o option. the value has to be non-negative. by default it uses the smallest ID value greater than or equal to GID_MIN and greater than every other group. ๐Ÿ‘‘

also peep the -r option and the GID_MAX description, iykyk.

  • -h, --help โ€” displays the help message and dips out. ๐Ÿ™ˆ
  • -K, --key KEY=VALUE โ€” overrides the /etc/login.defs defaults (GID_MIN, GID_MAX and others, she's flexible). you can stack multiple -K options, no problem.

example: -K GID_MIN=100 -K GID_MAX=499

note: -K GID_MIN=10,GID_MAX=499 doesn't work yet. ๐Ÿ˜ญ don't try it, it's not ready.

  • -o, --non-unique โ€” permits creating a group with an already used numerical ID. as a result, for this GID, the mapping towards group NEWGROUP may not be unique. so like, sharing is allowed, but the vibes get a lil chaotic. ๐Ÿ’€
  • -p, --password PASSWORD โ€” defines an initial password for the group account. PASSWORD is expected to be encrypted, as returned by crypt (3).

without this option, the group account will be locked and with no password defined, i.e. a single exclamation mark in the respective field of the system account file /etc/group or /etc/gshadow.

note: this option is not recommended because the password (or encrypted password) will be visible by users listing the processes. literally everyone can see it bestie, please.

you should make sure the password respects the system's password policy.

  • -r, --system โ€” creates a system group. ๐ŸŒˆ

the numeric identifiers of new system groups are chosen in the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs, instead of GID_MIN-GID_MAX.

  • -R, --root CHROOT_DIR โ€” applies changes in the CHROOT_DIR directory and uses the configuration files from the CHROOT_DIR directory. only absolute paths are supported. no SELINUX support. ๐Ÿšช
  • -P, --prefix PREFIX_DIR โ€” applies changes to configuration files under the root filesystem found under the directory PREFIX_DIR. this option does not chroot and is intended for preparing a cross-compilation target. some limitations, heads up: NIS and LDAP users/groups are not verified. PAM authentication is using the host files. no SELINUX support.
  • -U, --users โ€” a comma-separated list of usernames to add as members of the group. ๐Ÿซถ

the default behavior (if the -g, -N, and -U options are not specified) is defined by the USERGROUPS_ENAB variable in /etc/login.defs.


๐ŸŽ€ CONFIGURATION ๐ŸŽ€

these configuration variables in /etc/login.defs change how this tool behaves, so listen up:

  • GID_MAX (number), GID_MIN (number) โ€” range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.

the default value for GID_MIN (resp. GID_MAX) is 1000 (resp. 60000).

  • MAX_MEMBERS_PER_GROUP (number) โ€” maximum members per group entry. when the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID).

the default value is 0, meaning there are no limits in the number of members in a group.

this feature (split group) permits limiting the length of lines in the group file. this is useful to make sure that lines for NIS groups are not larger than 1024 characters.

if you need to enforce such a limit, you can use 25.

note: split groups may not be supported by all tools (even in the Shadow toolsuite). you should not use this variable unless you really need it. fr fr.
  • SYS_GID_MAX (number), SYS_GID_MIN (number) โ€” range of group IDs used for the creation of system groups by useradd, groupadd, or newusers.

the default value for SYS_GID_MIN (resp. SYS_GID_MAX) is 101 (resp. GID_MIN-1).


๐Ÿ“ FILES ๐Ÿ“

  • /etc/group โ€” group account information. ๐Ÿ—‚๏ธ
  • /etc/gshadow โ€” secure group account information. ๐Ÿ”
  • /etc/login.defs โ€” shadow password suite configuration. โš™๏ธ

๐Ÿ˜ญ CAVEATS ๐Ÿ˜ญ

  • you may not add a NIS or LDAP group. this must be performed on the corresponding server. not your job, not your problem, go ask the server. ๐Ÿ’…
  • if the groupname already exists in an external group database such as NIS or LDAP, groupadd will deny the group creation request. she said no. ๐Ÿšซ

๐Ÿ’€ EXIT VALUES ๐Ÿ’€

groupadd exits with these values, so you know exactly what happened:

  • 0 โ€” success ๐ŸŽ‰
  • 2 โ€” invalid command syntax
  • 3 โ€” invalid argument to option
  • 4 โ€” GID is already used (when called without -o)
  • 9 โ€” group name is already used
  • 10 โ€” can't update group file

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

chfn(1), chsh(1), passwd(1), gpasswd(8), groupdel(8), groupmod(8), login.defs(5), useradd(8), userdel(8), usermod(8).


and that's the whole page bestie!! this one's from shadow-utils 4.20.0, dated 07/30/2026 โ€” go forth and make groups, you absolute icon ๐Ÿ‘‘๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from