groupmod's Examples

this command modifies the group id por group name

groupmod mygroup

it is used to change the grpoup name

groupmod -n favourite mygroup

this command is used to change the group id

groupmod -g  GID groupname

it is used to change already assigned GId to the the group

groupmod -o mygroup

it is used to chnage the password of the group

groupmod -p mygroup

it is used to change the groupname

groupmod -n mygroup

this command helps with the groupmod commands

groupmod -h

Explanation:
Renames oldgroup to newgroup.

sudo groupmod -n newgroup oldgroup

Explanation:
Changes the Group ID (GID) of developers to 1050.

sudo groupmod -g 1050 developers

Explanation:
Renames developers to eng_team and assigns it GID 2000.

sudo groupmod -g 2000 -n eng_team developers

Output Example:

developers:x:1050:

Explanation:
Displays the group name and GID.

getent group developers

Explanation:
Verifies whether GID 1050 is already assigned.

getent group | grep 1050

Explanation:
Modifies sysadmins as a system group (GID < 1000).

sudo groupmod -r sysadmins

Explanation:
Locks the project_team group to prevent changes.

sudo groupmod -L project_team

Explanation:
Unlocks the project_team group.

sudo groupmod -U project_team

Explanation:
Assigns a password to the project_team group.

sudo gpasswd project_team

Explanation:
Lists all groups and their details.

cat /etc/group
or
getent group

DevOpsSchool
Typically replies within an hour

DevOpsSchool
Hi there 👋

How can I help you?
×
Chat with Us