Donate : Link
Medium Blog : Link
Applications : Link
groupmod command in Linux is used to modify or change the existing group on Linux system. It can be handled by superuser or root user. Basically, it modifies a group definition on the system by modifying the right entry in the database of the group.
~# groupmod --help
Usage: groupmod [options] GROUP
Options:
-g, --gid GID change the group ID to GID
-h, --help display this help message and exit
-n, --new-name NEW_GROUP change the name to NEW_GROUP
-o, --non-unique allow to use a duplicate (non-unique) GID
-p, --password PASSWORD change the password to this (encrypted) PASSWORD
-R, --root CHROOT_DIR directory to chroot into
-P, --prefix PREFIX_DIR prefix directory where are located the /etc/* files
Files: The groupmod command has following files.
- /etc/group: Group Account Information.
- /etc/gshadow: Secured group account information.
- /etc/login.def: Shadow passwd suite configuration.
- /etc/passwd: User account information.
Using groupmod with options:
1. -g, –gid GID
~# tail -1 /etc/group
cf:x:1001:
~# groupmod -g 1002 cf
~# tail -1 /etc/group
cf:x:1002:
2. -n, –new-name NEW_GROUP
~# tail -1 /etc/group
cf:x:1002:
~# groupmod -n CodeFactory cf
~# tail -1 /etc/group
CodeFactory:x:1002:
3. -o, –non-unique
~# tail /etc/group
CodeFactory:x:1002:
code:x:1003:
~# groupmod -g 1002 code
groupmod: GID '1002' already exists
~# groupmod -og 1002 code
~# tail /etc/group
CodeFactory:x:1002:
code:x:1002:
4. -p, –password PASSWORD
~# groupmod -p Abc@1 code
~# tail /etc/gshadow
CodeFactory:!::
code:Abc@1::
5. -R, –root CHROOT_DIR
~# groupmod -R / code
6. -P, –prefix PREFIX_DIR
~# groupmod -P / code

