The groupadd command is used to create new groups on a server. Which is used to manage user groups and their permissions.
- It is a command used to add groups into the Linux system.
- It comes from “shadow-utils”(RedHat) or “passwd” (Ubuntu) package.
- Below are associated configuration files:
/etc/group Group account information.
/etc/gshadow Secure group account info.
/etc/login.defs Shadow password suite configuration.
Examples:
1. To create a new group with name as “SUPPORT”
# groupadd SUPPORT |
![](https://www.unixforte.com/wp-content/uploads/2023/05/Groupadd.png)
2. To show success status if the group with name “SUPPORT” already exists or not.
# groupadd -f SUPPORT # groupadd –force SUPPORT |
3. To specify the numerical group ID while creating it.
# groupadd -g 504 SUPPORT # groupadd –gid 504 SUPPORT |
4. To get the help for the “groupadd” command.
# groupadd -h # groupadd –help |
5. To specify the “/etc/login.defs” values
# groupadd -K KEY=VALUE # groupadd –key KEY=VALUE # groupadd -K GID_MIN=100 # groupadd -K GID_MAX=499 |
6. To add a group with name as “SUPPORT” with non-unique value,
# groupadd -o 500 SUPPORT # groupadd –non-unique 500 SUPPORT |
7. To specify the encrypted password for the group named as “SUPPORT”.
# groupadd –password !$424733244%^12124 SUPPORT |
8. When you want to create a system group, instead of a normal user group.
# groupadd -r 499 SUPPORT |
Related Commands: chfn, chsh, passwd, gpasswd, groupdel, groupmod, login.defs, useradd, userdel, usermod
groupadd command not found
What if you get the message that “groupadd command is not found”, that means it is the below listed package is not installed on respective system.
OS Version | Package Details |
RedHat / CentOS / Fedora | shadow-utils |
Debian / Ubuntu / Kubuntu | passwd |
groupadd permission denied
If you receive the “groupadd: Permission denied”, then that means your user account does not have right permission to run that command. Hence give sudo rights to user by editing the “/etc/sudoers” file and adding below entry,
username ALL= (ALL:ALL) /usr/sbin/groupadd |