# 02-C.12: Groups: Create, Modify, and Delete - Modify Group


## Modify /etc/group File

The proper way to edit /etc/group file is using vigr commands in Linux. We CANNOT simply edit the groups file with a text editor. The vigr command is used to safely edit the files /etc/group file. It will put appropriate locks when editing /etc/group file to prevent other users from making any changes in the file and avoid file corruption. When you run this command with -s flag, it will edit the /etc/gshadow file.

As we have the ability to add, modify and delete users, we also have the ability to add, modify and delete groups. This video discusses these capabilites and shows examples of each.

### The vigr Command

The vigr command edits the /etc/groups file in the same manner that the vipw command edits the /etc/passwd file. The discussion can be found on the preceding page.

To safely edit /etc/groups file, simply run:



#### The groupmod Command

The groupmod command gives system administrators the ability to change the group's own attributes. The changes are made to the /etc/group.

Syntax:

groupmod [ OPTIONS ] GROUP_NAME


Command Options:

Option How is it used... Show me
-g The group id will be changed to the given value for the specified group. groupmod -g 999 security-team
-n The name of the specified group will be changed to the new group name. groupmod -n teamsec security-team
-o Allows for the creation of a non-unique GID. groupmod -o -g 217 sales

To change the name of our developers group to dev_team we use a simple command using th e-n option:

pbmac@pbmac-server $groupmod -n dev_team developers  #### The groupdel Command The groupdel command modifies the system account files, deleting all entries that refer to the specified group. The named group must exist. Syntax: groupdel [ OPTIONS ] GROUP_NAME Command Options: Options Option Meaning -g, --gid GID The group ID of the given GROUP will be changed to GID. Any files that have the old group ID and must continue to belong to GROUP must have their group ID changed manually. -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, allows to change the group GID to a non-unique value. -p, --password PASSWORD The encrypted password, as returned by crypt(3). An example of deleting the existing group sales: pbmac@pbmac-server$ groupdel dev_team


Be careful when deleting groups as it may cause users to have issues accessing resources. Also, take note that this command does NOT delete the users associated with the deleted group.

This page titled 02-C.12: Groups: Create, Modify, and Delete - Modify Group is shared under a CC BY-NC license and was authored, remixed, and/or curated by Patrick McClanahan.