Change Group name in Ubuntu

Published: October 08, 2022

Change Group name in Ubuntu

In previous article, we have covered how to change Group ID in Ubuntu. We can also change a Group's name in Ubuntu. Just to brief you about Groups, if you haven't gone through previous article. There are mainly two types of groups -

  1. Primary group and,
  2. Secondary group.

A primary group is created with the same name as that of user. And, we can have a user associated with multiple secondary groups.

We can change Group name in Ubuntu using groupmod command-line utility.

Note: Following operations require superuser privileges. In case you don't have one then, we advise you to contact your System Administrator for assistance.

Change Group name in Ubuntu

Use the following syntax to change group name in Ubuntu -

sudo groupmod -n <new_group_name> <group_name>

or, we can also use -

sudo groupmod --new-name <new_group_name> <group_name>

For instance, we already have a group - qwerty and to rename it as - xyz. Issue the following -

sudo groupmod -n xyz qwerty

The above command will change the qwerty group name to xyz.

To view the changes made, use cat command-line utility -

cat /etc/group | grep <new-group-name>

here, <new-group-name> should be the current group name. From here, we can verify that - in place of previously used group name we now have new group name available. And, rest all fields in /etc/group file stay as it is.

In conclusion, we have covered how to change group name in Ubuntu.

Additional Info -

What we covered above should not be confused with chgrp command-line utility. The purpose of chgrp command is to change a group ownership of files, directories etc. Whereas, -n or --new-name command options with groupmod would change the name of the group.