×

addgroup Command in Linux with Examples

What is the addgroup command?

It is a command in Linux to create a new group using specified command lined and the system’s default values.

How to add groups

  • Adding a user group: If we want to add a user group, we either call adduser with the –group option without using the –system option, or we call addgroup.
  • Adding a system group: To add a system group, we call addgroup with the –system option. Here also, the group created will have no users.
  • Adding an existing user to a group that already exists: If the adduser is run with two non-option arguments, then the user is added to a group if it already exists.

Syntax:

adduser [--system] [--home DIR] [--shell SHELL] [--no-create-home]
        [--uid ID] [--firstuid ID] [--lastuid ID]
        [--ingroup GROUP | --gid ID] [--disabled-password]
        [--disabled-login] [--gecos GECOS] [--add_extra_groups]
        [--encrypt-home] [--quiet] [--debug] [--force-badname]
        [--help|-h] [--version] [--conf FILE] user


addgroup [--system] [--quiet] [--debug] [--force-badname] [--help|-h]
         [--version] [--conf FILE] [--gid ID] group
adduser [options] usergroup

 Some options used in the above line code are explained here:

--conf FILE    This option use FILE in place of /etc/adduser/conf.
--disabled-loginThis option makes the user set a password for his account, or else he would not be able to use his account.
--disabled    password     This option is similar to –disabled-login, but the user can log in to his account without using a password.
--force-badnameThe user and group names are checked, by default. So, this option pressures adduser and addgroup to check roughly for the cogency of the name.
--gecos GECOSThis option will restrict the adduser to ask for finger information.
--gid IDWhen this option is used, the given number is forced to bethe new group ID. If a user is created/added, due to this option he is added to that group.
--group         If we want to create the group with the same name as the system user, we combine this option with the --system. If this option is not combined with the --system, then the group with the given name is created.
--helpThis option is used to show a help message and exit.
--home DIR  If we use DIR as the user’s home directory, then if the directory does not exist, it is created and the skeleton files are copied.
--quiet           This option only displays errors and warnings and hides informational messages.
--systemThis option creates a system group or system user.
--add_extra_groupsThis option adds a new user to extra groups.
--versionThis option shows copyright information and version.

Configuration

The file /etc/adduser.conf holds defaults for the programs. Every line contains a single value pair in the form “option = value”. A hash sign (#) is compulsory in a comment line.

Some of the valid configuration options are:

DSHELLThis is the log-in shell that is used for all users. Reverts to /bin/bash.
DHOMEThis is the directory where the new home directories have to be created. Reverts to /home.
GROUPHOMESThe home directory is created as “/home/[groupname]/user” if set to yes. Reverts to no.
SKEL   This is the directory from which the user configuration files have to be copied. Reverts to /etc/skel.
LETTERHOMESThe home directories have an extra directory added that is the first letter of the login name if this is set to yes.

Files

/etc/adduser.confIt is a revert layout for adduser and addgroup.

Working on addgroup command in Linux

  • For adding a new group
sudo addgroup groupname
addgroup Command in Linux with Examples

This command creates a new group for our Linux Machine.

  • For adding a new group with a specified Group ID (GID)
sudo addgroup groupname --gid 12345
addgroup Command in Linux with Examples

This command adds a new group with a specified Group ID (GID).

  • For creating a group with a specific shell
sudo addgroup groupname --shell /bin/sh
addgroup Command in Linux with Examples

The /bin/sh shell is allocated to the newly created group with the help of this command.

  • For entering verbose mode
sudo addgroup groupname --debug
addgroup Command in Linux with Examples

All the commands will be executed in the verbose mode i.e., all the details of the operations being performed will be printed, when this command is used.

  • ToFor show help related to the addgroup command
addgroup –help
addgroup Command in Linux with Examples

The help section of the addgroup command can be displayed using this command.

  • For displaying version
addgroup –version
addgroup Command in Linux with Examples

To show version details of the addgroup command, the version command is used.


Related Topics

adduser Command in Linux with Examples

What is the adduser command? The adduser command creates a new user, and this command may be used to add apre-existing user to a group that already exists. How to use the...

4 minutes read.

cat Command in Linux/Unix with Examples

The cat command in Linux is a command-line utility that is used to display the contents of a text file. It stands for "concatenate" and it is used to view...

4 minutes read.

man Command in Linux/Unix with Examples

The man command in Linux is used to display the manual pages for a given command or system call. These manual pages provide detailed information on the command's usage, options,...

3 minutes read.

sed Command in Linux/Unix with Examples

The 'sed' command in Linux is a powerful text processing tool that allows you to perform various operations on text files, such as searching, replacing, and manipulating text. The command...

3 minutes read.

telnet Command in Linux/Unix with Examples

The telnet command in Linux is a command-line utility that allows you to connect to a remote host using the Telnet protocol. Telnet is a network protocol that provides a...

3 minutes read.

df Command in Linux/Unix with Examples

The 'df' command in Linux is used to display the amount of disk space available on the file system. The command reports the amount of disk space used and available...

3 minutes read.

cd Command in Linux/Unix with Examples

The 'cd' command in Linux is used to change the current working directory. The command stands for "change directory" and it is used to navigate the file system on a...

3 minutes read.

rename Command in Linux/Unix with Examples

The rename command in Linux is used to rename multiple files at once, using a specified pattern. The command is also known as rename, ren, and mv. This command is...

3 minutes read.

ps Command in Linux/Unix with Examples

The 'ps' command in Linux is used to display information about the running processes on a system. The command stands for "process status" and it allows you to view details...

4 minutes read.

ssh Command in Linux/Unix with Examples

The ssh (Secure Shell) command in Linux is used to remotely access and control another computer or device over a network. It provides a secure and encrypted connection between the...

6 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.

Top 20 Linux Commands

1) clear command clear is a standard operating system command which is used to clear the terminal screen. This command brings the command line on the top of the terminal. By pressing the...

10 minutes read.

ping Command in Linux/Unix with Examples

The "ping" command in Linux (and other Unix-like operating systems) is used to test the connectivity between two networked devices. The "ping" command sends a small packet of data, called...

4 minutes read.

Linux SCP Command

SCP stands for secure copy protocol. It is a command-line application for copying files and directories safely between two places. Command-line utilities are programs that operate on a computer's command...

3 minutes read.

Linux Absolute and Relative Path

The concept of the absolute and relative path is very simple. The names “relative path” and “absolute path” give us little understanding of the concept we are learning here. The...

1 minute read.

Difference Between Unix and Linux

Unix vs Linux Unix and Linux both have been of great use in changing the world of operating systems. Unix was among the very few operating systems which were programmed for...

4 minutes read.

Difference Between Linux and Windows

Linux vs. Windows Here in this tutorial, we are going to discuss several features of Linux and Windows. These features or characteristics help us to come to a conclusion about which...

5 minutes read.

netstat Command in Linux/Unix with Examples

The "netstat" command in Linux is a command-line utility that displays network connections, routing tables, and various network statistics. It is used to display the status of network connections, both...

3 minutes read.

Linux rmdir command

The default use case of the rmdir command in the Linux system is to delete an empty directory. The below screenshot shows how to delete the empty directory. First, we...

1 minute read.

echo Command in Linux/Unix with Examples

The "echo" command in Linux is used to display a line of text on the terminal. It can also be used to print the value of a variable or to...

3 minutes read.