LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

groupmod

modify a group definition

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
-a, --append
With -U, append the given users to the group's existing members instead of replacing the list
-U, --users USER[,USER,...]
Comma-separated list of usernames to set as the group's members
-R, --root CHROOTDIR_
Apply changes in chroot environment
-P, --prefix PREFIXDIR_
Apply changes in prefix directory (uses config files there without chrooting)
-h, --help
Display help message and exit

INSTALL

sudo apt install passwd
copy
sudo pacman -S shadow
copy
sudo apk add shadow
copy
sudo zypper install shadow
copy
nix profile install nixpkgs#shadow
copy

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
Kai