Closed Captioning Closed captioning available on our YouTube channel

How to use the groupmod command: 2-Minute Linux Tips

Network World | Dec 4, 2020

In this Linux tip, learn how to use the groupmod command. It’s a command that allows you to change the name of a user group. It does this by changing the entry in the /etc/group file (the line that connects the group name with the group number) and, thus, the group that shows up when you do a long file listing.

Copyright © 2020 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the groupmod command. It’s a command that allows you to change the name of a user group. It does this by changing the entry in the /etc/group file (the line that connects the group name with the group number) and, thus, the group that shows up when you do a long file listing. If the group includes a number of users, all of them will see a change when they list their files with the ls -l command.
Before I run the groupmod command, I’ll run a couple commands to display the group I’m about to change:
$ grep admin /etc/group
admin:x:11:shs,shark
lpadmin:x:118:
$ ls -l shared-doc
-rw-rw-r-- 1 shs admin 1016 Aug 11 09:15 shared-doc
Now I run this command to change the group name from admin to secteam:
$ sudo groupmod -n secteam admin
Note that you need to use sudo to change group names and that I am only changing the name associated with the group ID (GID).
So, now that I’ve run the command, I will look at the entry in the /etc/group file that I just changed:
$ grep secteam /etc/group
secteam:x:11:shs,shark
Notice that the only change is the name of the group. Since this change was to a secondary group – not the users’ primary group, it will only show up when files associated with that group are listed.
The groupmod command can also be used to rename a user’s primary group – something you are likely to want to do if you change someone’s username.
That’s your Linux tip for the groupmod command. Refer to the man page for more information on this command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Popular
Featured videos from IDG.tv