In this Linux tip, we’re going to look at the groupmod command. Groupmod Command in Linux is a command that allows you to change the name of a user group. SuperUser or root User is only allowed to change the group. It does this by changing the entry in the esty group file. The line that connects the group name of the group number and thus the group that shows up when you do long file listings. If the group includes a number of users, all of them will see the change when they list their shared files.
Now Before I run the groupmod command, I am going to run a couple commands to display the group that I am about to change.
Informationhub is User and
infohubblog is Group
groupmod command consists of files
- /etc/group : It consist of group to which user belong in Linux.
- /etc/passwd : It consist of all user that are registered to the system. It keeps track of registered user.
In order to change the group of files or folders run the below command and then you will see that the following group will be associated with that file or folder. In the screenshot below, you can see
infohubblog group get associated with samplefile.
chgrp groupname filename chgrp groupname foldername
Groupmod command in Linux Options
|-g, –gid GID||The group ID of the given GROUP will be changed to GID|
|-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 name.|
|-o, –non-unique||When used with the -g option, allow changing the group GID to a non-unique value.|
|-p, –password PASSWORD||The encrypted password, as returned by crypt(3)|
|-R, –root CHROOT_DIR||Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.|
|-P, –prefix PREFIX_DIR||Apply changes in the PREFIX_DIR directory and use the configuration files from the PREFIX_DIR directory.|
This command will rename the group with the new group name.
groupmod new_group old_group
Hope you like our Blog. If you want to get an update on the latest blog then Please do subscribe to our newsletter.