Important Groupmod Command in Linux with Example

maxresdefault 4

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.
Groupmod Command in Linux
  • /etc/passwd : It consist of all user that are registered to the system. It keeps track of registered user.
Groupmod Command in Linux

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

Groupmod command in Linux Options

-g, –gid GIDThe group ID of the given GROUP will be changed to GID
-h, –helpDisplay 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-uniqueWhen used with the -g option, allow changing the group GID to a non-unique value.
-p, –password PASSWORDThe encrypted password, as returned by crypt(3)
-R, –root CHROOT_DIRApply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-P, –prefix PREFIX_DIRApply 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
Groupmod Command in Linux

Hope you like our Blog. If you want to get an update on the latest blog then Please do subscribe to our newsletter.

You can even look into our Linux Blog – Linux Networking Command, LvExtend Command, Linux Terminal Command


Leave a comment

Your email address will not be published.