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 systems that runs on desktops, laptops, server and other devices.
About groupmod command:
The groupmod command is used by system administrators to manage groups on Linux systems. It allows superuser to perform basic 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 systax’s options can be reordered. but straight format must be followed.,.
Below is an example syntax of how to use the groupmod comamnd.
groupmod [options] GROUP
Options:
The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the command. they are separated by spaces and followed after the commands options.
Below are some options of 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 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 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.
If you want to change a group named male to female, run the commands below.
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 it it.
sudo groupmod -g 777 female
To enable two groups to have the same ID, use the commands below. When -o is used with -g option we can give non unique 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!
Hope you like it and please come back soon for more Ubuntu Linux command!
You may also like the commands below: