The groupmod command is used by system administrators to manage groups on Linux systems.
When you’re learning how to use and manage Linux systems, the best place to start might be on Ubuntu Linux OS.
Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.
About groupmod command:
The groupmod command is used by system administrators to manage groups on Linux systems. In addition, it allows superusers to perform essential group management.
Like using your mouse and keyboard to change group settings in the GUI., the groupmod is the way to do it on the command line.
Syntax:
The syntax is the rule and format of how the groupmod command can be used. The syntax options can be reordered. But a straight format must be followed.,.
Below is an example syntax of how to use the groupmod command.
groupmod [options] GROUP
Options:
The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the command. They are separated by spaces and followed after the command options.
Below are some options for the groupmod command:
GROUP | Replace GROUP with the name of the group you want to change its settings. If the group doesn’t already exist, the command will fail and not execute. |
-g, –gid GID | Use the -g or –gid GID option to set or change the group ID to GID |
-n, –new-name NEW_GROUP | Use the -n or –new-name NEW_GROUP option to change the group name to NEW_GROUP. |
-o, –non-unique | Use the -o or –non-unique option to allow to use of a duplicate (non-unique) GID |
-p, –password PASSWORD | Use the -P or –password PASSWORD option to change the password to this (encrypted) PASSWORD |
-R, –root CHROOT_DIR | Use the -R or –root CHROOT_DIR option sets the directory to chroot into |
-h, –help | display this help message and exit |
Examples:
Below are some examples of how to run and use the groupmod on Ubuntu Linux.
Run the commands below if you want to change a male to a female group.
groupmod -n female male
If you wish to change the female group ID to 777, run the commands below.. the command changes the female group ID to 777.
groupmod -g 777 female
If you’re not logged in as a root account, you may have to use the sudo command.
sudo groupmod -g 777 female
Use the commands below to enable two groups to have the same ID. When -o is used with the -g option, we can give nonunique values
sudo -g 777 -o male
Both the female and male groups have the same ID of 777
When you run groupmod with the –help option, you’ll see the help text below:
Usage: groupmod [options] GROUP Options: -g, --gid GID change the group ID to GID -h, --help display this help message and exit -n, --new-name NEW_GROUP change the name to NEW_GROUP -o, --non-unique allow to use a duplicate (non-unique) GID -p, --password PASSWORD change the password to this (encrypted) PASSWORD -R, --root CHROOT_DIR directory to chroot into
That’s it!
I hope you like it, and please come back soon for more Ubuntu Linux commands!
You may also like the commands below: