LinuxCommandLibrary

groupmod

TLDR

Change the group name

$ sudo groupmod -n [new_group] [group_name]
copy
Change the group ID
$ sudo groupmod -g [new_id] [group_name]
copy

SYNOPSIS

groupmod [options] group

DESCRIPTION

groupmod modifies the attributes of an existing group on the system. It can change the group name, group ID (GID), or group password.
When changing GID, files owned by the group are NOT automatically updated. You must manually find and update file ownership using commands like find / -gid OLDGID -exec chgrp NEWGROUP {} \;.
Changing a group name has no effect on file ownership since files reference groups by GID, not name.

PARAMETERS

-g, --gid GID

Change group ID to GID
-n, --new-name NAME
Change group name to NAME
-o, --non-unique
Allow non-unique GID
-p, --password PASSWORD
Set encrypted group password
-R, --root CHROOTDIR_
Apply changes in chroot environment
-P, --prefix PREFIXDIR_
Apply changes in prefix directory

CAVEATS

Changing GID does not update file ownership automatically. Users must log out and back in for group changes to take effect. Cannot change a group to a name or GID that already exists (unless -o is used for GID).

HISTORY

groupmod is part of the shadow-utils package, which has been the standard for Unix group management across Linux distributions. It provides safe modification of the /etc/group and /etc/gshadow files.

SEE ALSO

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

Copied to clipboard