“groupmod” Command usage Examples in Linux

«
»

This tutorial explains Linux “groupmod” command, options and its usage with examples.

groupmod – Modify a group

Description :

advertisement

The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database.

Usage :

groupmod [options ] group

Options :

advertisement
advertisement

-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”.

advertisement
# 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

advertisement
# groupmod -g 777 -o abc1

Hence abc and abc1 groups have 501 as GID.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.