• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

groupadd Command Examples in Linux

by admin

The groupadd command creates a group. By default, the group has no members and no passwords. In addition to creating a group with a friendly name, you can also specify a group ID using the -g option.

Below are associated configuration files:

  • /etc/group: Group account information.
  • /etc/gshadow: Secure group account info.
  • /etc/login.defs: Shadow password suite configuration.

Syntax

The syntax of the groupadd command is:

# groupadd [options] {group names}

Some groupadd options include the below.

Option Used To Example
-f Assign a group ID. # groupadd -g 123 sales
-f Exit with success if group already exists # groupadd -f sales
-o Allow group creation with non-unique ID # groupadd -o -g 123 sales

groupadd Command Examples

1. To create a new group:

# groupadd SUPPORT 

2. To show success status if the group already exists:

# groupadd -f SUPPORT
# groupadd --force SUPPORT

3. To specify the numerical group ID:

# groupadd -g 504 SUPPORT
# groupadd --gid 504 SUPPORT

4. To get the help info:

# 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 non-unique vale:

# groupadd -o 500 SUPPORT
# groupadd --non-unique 500 SUPPORT 

7. To specify the encrypted password for group:

# groupadd --password !$424733244%^12124 SUPPORT 

8. To create a system group:

# groupadd -r 499 SUPPORT 

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to find the creation time of LVM volume
  2. xxd command – Expressed in hexadecimal form
  3. nm : Command to list the symbols in object files.
  4. What is Anacron and usage of Anacron in Linux
  5. How to disable or enable an HBA without reboot under CentOS/RHEL
  6. LVM Commands Fail With “Failed to load config file /etc/lvm/lvm.conf”
  7. How to Enable Debug Mode for Chronyd Service in CentOS/RHEL 8
  8. Linux OS Service ‘microcode_ctl’
  9. Log watching using tail or less
  10. How to Add Network Printer via Command Line in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright