The groupadd command is used by system administrators to add / create groups on Linux systems
Ubuntu is a great place to start for new users and students learning how to use and manage Linux systems. It’s a great platform for beginners to start learning Linux on.
Ubuntu is an open-source Linux operating systems that runs on desktops, laptops, server and other devices.
About groupadd command:
The groupadd command is used by system administrators to add / create groups on Linux systems. It allows superuser to perform basic 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 the way to do it on the command line.
The syntax is the rule and format of how the groupadd 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 groupadd comamnd.
groupadd [options] GROUP
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 groupadd 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..|
|-f, –force||Use the -f or –force option to exit with a success message if the group already exists. When used with -g option and the group exist, a new GID is created|
|-g, –gid GID||Use the -g or –gid GID for the new group you’re creating.|
|-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|
Below are some examples of how to run and use the groupadd on Ubuntu Linux.
If you want to create a new group named members, you run the commands below.
If you wish to create a members group with GID of 8080, you run the commands below. 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 it it.
sudo groupadd -g 8080 members
When it is assigning the automatic group id, it uses the GID_MIN, and GID_MAX value specified in the /etc/login.defs config file. f you want to set your own values, you can specify that using -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 that 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 Options: -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
Hope you like it and please come back soon for more Ubuntu Linux command!