addgroup command in Linux with Examples
Last Updated :
09 Oct, 2024
The add group command in Linux adds a new group to your current machine and allows you to modify its configuration. It is similar to the groupadd command, but it is more interactive and user-friendly.
Syntax
sudo addgroup [ options ] groupname
Installing the addgroup Command
If the addgroup tool is not already installed, you can install it based on your Linux distribution using one of the following commands
1. In case of Debian/Ubuntu
$sudo apt-get install addgroup
2. In case of CentOS/RedHat
$sudo yum install addgroup
3. In case of Fedora OS
$sudo dnf install addgroup
Key Options Used with addgroup Command
1. Add a New Group:
To add a new group, simply use the addgroup command followed by the group name.
sudo addgroup groupname

This command will create a new group for your Linux machine.
2. Add a New Group with a Specific Group ID (GID):
To create a group with a specified GID, use the --gid option.
sudo addgroup groupname --gid 12345

This command will add a new group with the specified group id.
3. Create a Group with a Specific Shell:
You can assign a specific shell to the group during its creation using the --shell option.
sudo addgroup groupname --shell /bin/sh

This command will allocate the /bin/sh shell to the newly create group.
4. Enter Verbose Mode:
To run the addgroup command in verbose mode and print details of all the tasks it is performing, use the --debug option.
sudo addgroup groupname --debug

This command will execute the command in the verbose mode that means it will print all details of the tasks it is executing.
5. Display Help:
To display the help section of the addgroup command, use the --help option.
addgroup --help

This command will display the help section of the addgroup command.
6. Display Version:
To check the version of the addgroup command, use the --version option.
addgroup --version

This command will display the version details of the addgroup command.
Conclusion
The addgroup command is a useful tool in Linux for creating and managing groups with additional configuration options such as group ID (GID) and shell assignment. Its user-friendly and interactive nature makes it a preferred choice over the groupadd command.