Users
The groupmod command
Changes the data of a group that already exists: its name, its numeric GID or its password. It does not create or delete groups; groupadd and groupdel do that.
Most useful options
-n NOMBRERenames the group. Member users stay in it-g GIDChanges the group number. Older files keep the previous number-oAllows a GID already used by another group. Use it only if you know why-p HASHChanges the encrypted group password. It expects the hash, not the textCopy-ready examples
$ sudo groupmod -n equipo_ventas comercialrenames the group comercial to equipo_ventas.$ sudo groupmod -g 1500 equipo_ventasassigns GID 1500. Files that already existed keep the previous GID.$ getent group equipo_ventaschecks the result: name, password, GID and members.Example output
equipo_ventas:x:1500:ana,beto
You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| groupmod: Permission denied. | You do not have administrator rights. | Put sudo in front of the command. |
| groupmod: group 'devs' does not exist | The group given does not exist, or the name has a typo. | Find the exact name with getent group or by checking /etc/group. |
| groupmod: GID '1001' already exists | The GID you ask for is already used by another group, and without -o the change is rejected. | Choose a free number or use -o if the duplicate is intended. |
Typical mistakes
- Renaming a group does not change file permissions, because Linux stores the number and not the name.
- If the group appears in sudoers or in rules of other programs, change it there too, because those references use the name.
- groupmod -p expects the already encrypted hash, not plain text. Writing the password as is leaves it unusable.
Differences from similar commands
Security
groupmod -g does not update existing files: they still point to the old number, which can become orphaned or end up assigned to another group. Before changing a GID, find those files with find -group and change them with chgrp. Changing the GID of a system group can break services.
FAQ
Do I need to reboot after renaming a group?
Not necessarily. Users with an open session will see the change when they log in again.
Can I change a group GID without losing files?
Yes, but afterwards you must change the files with chgrp or find -group, because they are not updated automatically.
How do I see the members of a group?
With getent group name, which shows the group users in the last column.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course