This tutorial explains Linux “groupmod” command, options and its usage with examples.
Description :
The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database.
Usage :
groupmod [options ] group
Options :
-g, –gid GID
The group ID of the given GROUP will be changed to GID. The value of GID must be a non-negative decimal integer. This value must be unique, unless the -o option is used. Users who use the group as primary group will be updated to keep the group as their primary group. Any files that have the old group ID and must continue to belong to GROUP, must have their group ID changed manually. No checks will be performed with regard to the GID_MIN, GID_MAX, SYS_GID_MIN, or SYS_GID_MAX from /etc/login.defs.
-h, –help
Display help message and exit.
-n, –new-name NEW_GROUP
The name of the group will be changed from GROUP to NEW_GROUP.
-o, –non-unique
When used with the -g option, allow to change the group GID to a non-unique value.
-p, –password PASSWORD
The encrypted password, as returned by crypt.
Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes. You should make sure the password respects the system’s password policy.
Examples :
1. Change the group “newgroup” to “bettergroup”.
# groupmod -n bettergroup newgroup
2. Change groupid of a group
This command changes the groupid of abc group to 777
# groupmod -g 777 abc
3. When -o is used with -g option we can give non unique values
# groupmod -g 777 -o abc1
Hence abc and abc1 groups have 501 as GID.
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Practice Programming MCQs
- Check Linux Books
- Apply for Programming Internship
- Check Information Technology Books