LinuxCommandLibrary

groupmod

Modify group attributes

TLDR

Change the group name

$ sudo groupmod [[-n|--new-name]] [new_group] [group_name]
copy

Change the group ID
$ sudo groupmod [[-g|--gid]] [new_id] [group_name]
copy

SYNOPSIS

groupmod [-g GID [-o]] [-n NEW_GROUP] [-h | -V] GROUP

PARAMETERS

-g, --gid GID
    Set the group ID of GROUP to the given GID.

-n, --new-name NEW_GROUP
    Rename GROUP to NEW_GROUP.

-o, --non-unique
    Permit non-unique group ID (only valid with -g); allows duplicate GIDs.

-h, --help
    Display usage information and exit.

-V, --version
    Output version information and exit.

DESCRIPTION

groupmod modifies an existing user group in the system's group database, typically /etc/group and /etc/gshadow. It allows changing a group's name or numeric group ID (GID), which is crucial for system administration tasks like reorganizing groups, fixing ID conflicts after migrations, or adapting to new policies.

Primary options include -n to rename the group and -g to assign a new GID. The -o flag enables non-unique GIDs when used with -g, permitting duplicate IDs in advanced scenarios such as NIS setups.

Changing a GID affects all users with that group as primary or supplementary, but files and processes owned by the old GID remain unchanged until manually updated with tools like chgrp or find. Administrators must ensure no active processes use the group to avoid access issues or security risks. Root privileges are required, and the command fails if the group does not exist or options conflict.

groupmod is part of the shadow password suite, ensuring secure, backward-compatible group management on modern Linux systems.

CAVEATS

Cannot modify a group in use by running processes; may cause file access issues. New GID must not exceed system limits (check /etc/login.defs). Renaming does not update files or services automatically—use chgrp. Fails if target name/GID already exists (unless -o).

FILES

/etc/group - Contains group name, GID, and member list.
/etc/gshadow - Secure group password and admin info.

EXIT STATUS

0: success.
1: syntax error.
2: invalid argument to option.
3: specified group doesn't exist.
4-10: GID/name conflicts or permission errors.

HISTORY

Developed as part of the Shadow Password Suite by Julianne Frances Haugh since 1991. Integrated into major Linux distributions (e.g., Red Hat, Debian) from the mid-1990s. Current versions (shadow 4.14+) support extended options like --non-unique for legacy network environments.

SEE ALSO

groupadd(8), groupdel(8), usermod(8), gpasswd(8), chgrp(1)

Copied to clipboard