How to use groupmod command on Ubuntu Linux with examples

|

|

The ‘groupmod’ command is used by system administrators to manage groups on Linux systems, especially on Ubuntu Linux OS. Through command line, it allows alterations to group settings, including changing a group’s name, ID and password among other features. Syntax options must be followed and include switches or flags to modify the command behavior.

The groupmod command is used by system administrators to manage groups on Linux systems.

The groupmod command is used by system administrators to manage groups on Linux systems. It allows superusers to perform essential group management tasks on the command line, such as changing a group’s name, ID, and password or allowing duplicate GIDs.

Using groupmod can help manage user permissions and access to files and directories on Ubuntu Linux systems. Additionally, learning how to use and manage Linux systems on Ubuntu is a great place to start for beginners, as it is an open-source operating system that runs on a wide range of 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:

GROUPUse the -o or –non-unique option to allow the use of a duplicate (non-unique) GID
-g, –gid GID
Use the -g or –gid GID option to set or change the group ID to GID
-n, –new-name NEW_GROUPUse the -n or –new-name NEW_GROUP option to change the group name to NEW_GROUP.
-o, –non-unique-o, –nonunique
-p, –password PASSWORDUse the -P or –password PASSWORD option to change the password to this (encrypted)
PASSWORD
-R, –root CHROOT_DIRUse the -R or –root CHROOT_DIR option set the directory to chroot int
-h, –helpdisplay 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 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:

Like this:



One response to “How to use groupmod command on Ubuntu Linux with examples”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.