groupmod: command not found

The groupmod command is used to change the group’s own attributes. It will edit the /etc/group file for you. Modifications of the group might include changing its name or GID. Adding a user to a group is considered to be a modification of the user, not the group. As such, it is accomplished using the usermod command.

Some groupmod options include the following.

Option Description
-g Change the group ID.
-n Rename a group.

Syntax

The syntax of the groupmod command is:

# groupmod [options] {group names}

To modify the name of a group after it has been created, use the groupmod command. To make the change, log in as the root user and enter the following command:

# groupmod -n newgroup currentgroup

where newgroup is the new name you want to give the group, and currentgroup is the current name of the group. For example, to change a group name from admin to geek, you would use the following command:

# groupmod -n geek admin

If you encounter below error while running the groupmod command:

groupmod: command not found

you may try installing the passwd package as shown below as per your choice of distribution.

Distribution Command
Debian apt-get install passwd
Ubuntu apt-get install passwd
Alpine apk add shadow
Arch Linux pacman -S shadow
Kali Linux apt-get install passwd
Fedora dnf install shadow-utils-2
Raspbian apt-get install passwd

groupmod Command Examples

1. Change the group ID:

# groupmod -g 123 group_name

2. Rename a group:

# groupmod -n new_group_name group_name

See the man page groupmod for a full list of all the command-line options available.

Related Post