How to use the groupmod command on Ubuntu 16.04 | 18.04 with Examples

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…

The same way you use your mouse and keyboard to manage groups or perform others simple tasks on Microsoft Windows OS, Ubuntu also makes it that easy for you… Just like how simple it is to work on Windows computers, Ubuntu desktop is easy as well and great for beginners…

However, when you’re learning to use and understand Ubuntu Linux, you’ll also want to learn the comnands behind the graphics and mouse-clicking… and how to use them…  This tutorial is going to show you how…..

This post shows new users and students what the groupmod command is and how to use it…

When you’re ready to learn how to use the groupmod commands, follow the guide below:

About groupmod command:

The groupmod command is used by system adminstrators 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:

Install Apache OpenMeetings on Ubuntu 16.04 / 18.04 with MariaDB

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.