How to use groupadd command on Ubuntu Linux with examples

Computer screen with mobile devices
Computer screen with mobile devices

The groupadd command is used by system administrators to add/create groups on Linux systems.

Ubuntu is an excellent place for new users and students to learn how to use and manage Linux systems. In addition, it’s an ideal platform for beginners to start learning Linux.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

About groupadd command:

The groupadd command is used by system administrators to add/create groups on Linux systems. In addition, it can perform essential group management on Ubuntu and other Linux platforms.

Like using your mouse and keyboard to add groups or manage settings in the GUI., the groupadd is how to do it on the command line.


The syntax is the rule and format of how the groupadd 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 groupadd command.

groupadd [options] GROUP


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 groupadd command:

    GROUPReplace 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.
-f, –force
Use the -f or –force option to exit with a success message if the group already exists. When used with the -g option and the group exist, a new GID is created
-g, –gid GIDUse the -g or –gid GID for the new group you’re creating.
-o, –non-uniqueUse the -o or –non-unique option to allow to use of a duplicate (non-unique) GID
-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 sets the directory to chroot into
-h, –helpdisplay this help message and exit


Below are some examples of how to run and use the groupadd on Ubuntu Linux.

To create a new group named members, you run the commands below.

groupadd members

You run the commands below if you wish to create a members group with a GID of 8080. by default, if you don’t specify a GID for a group, Linux automatically assigns one.

groupadd -g 8080 members

If you’re not logged in as a root account, you may have to use the sudo command.

sudo groupadd -g 8080 members

Assigning the automatic group id uses the GID_MIN and GID_MAX values specified in the /etc/login. defs config file. f you want to set your values, you can specify that using the -K option, as shown below

sudo groupadd -K GID_MIN=8080 -K GID_MAX=8090 members

In the example above, the groupadd command created the account with group id 8081, which is between the values 8000 – 9999 we specified in the command line.

When you run groupadd with the –help option, you’ll see the help text below:

Usage: groupadd [options] GROUP

  -f, --force                   exit successfully if the group already exists,
                                and cancel -g if the GID is already used
  -g, --gid GID                 use GID for the new group
  -h, --help                    display this help message and exit
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -o, --non-unique              allow to create groups with duplicate
                                (non-unique) GID
  -p, --password PASSWORD       use this encrypted password for the new group
  -r, --system                  create a system account
  -R, --root CHROOT_DIR         directory to chroot into
      --extrausers              Use the extra users database

That’s it!

I hope you like it, and please come back soon for more Ubuntu Linux commands!

Posted by

I love computers; maybe way too much. What I learned I try to share at

Leave a Reply

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

%d bloggers like this: