The groupadd command is a Linux command-line utility used to create new groups in the system. In this tutorial, we'll go over the basics of the groupadd command and its usage.
The basic syntax for the groupadd command is:
groupadd [options] group_name
Here are some common options used with the groupadd command:
-g: Specify the Group ID (GID) for the new group.-r: Create a system group with a GID less than 1000.-K: Overwrite the default value for specified key (e.g., GROUP_ADD_CMD).Here are some examples to illustrate the usage of the groupadd command:
developers:sudo groupadd developers
sudo groupadd -g 1500 developers
sudo groupadd -r sysgroup
sudo groupadd -K GID_MIN=500 -K GID_MAX=2000 customgroup
To verify that the group was created successfully, you can check the /etc/group file, which contains a list of all groups in the system:
grep 'group_name' /etc/group
Replace group_name with the name of the group you created.
In summary, the groupadd command is a useful utility for creating new groups in Linux. It allows you to create system and non-system groups and specify the GID when needed. Make sure to run the command as root or with sudo to have the necessary privileges.
How to use the groupadd command in Linux:
groupadd is a command-line utility in Linux used to create new user groups.sudo groupadd groupname
Adding user groups with groupadd:
groupadd to add a new user group to the system.sudo groupadd mygroup
Creating new groups in Linux using groupadd:
groupadd is used to create new groups on the system.sudo groupadd newgroup
Setting group ID and additional options with groupadd:
-g option.sudo groupadd -g 1001 mygroup
Checking existing groups before using groupadd:
grep command along with /etc/group.grep mygroup /etc/group
Adding users to newly created groups with groupadd:
usermod command to add users to it.sudo usermod -aG mygroup username
Viewing group information in Linux after using groupadd:
getent command to view information about a specific group.getent group mygroup
cashapelayer networkimageview project-reference facet-wrap chart.js2 href qstackedwidget presto string-substitution comdlg32