• 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. certbot Command Examples in Linux
  2. cp: omitting directory – error while copying a directory in Linux
  3. Getting info with the vsish command (esxi only)
  4. alias: command not found
  5. How to use “xfs_admin” command to change parameters of an XFS filesystem
  6. rmmod: command not found
  7. Understanding /proc/meminfo file (Analyzing Memory utilization in Linux)
  8. User Environment Variables With “su” and “sudo” in Linux
  9. CentOS / RHEL 6,7 : How to recover an interrupted yum package installation
  10. UNIX / Linux : How to delete root equivalent user (Non-Root User with UID 0)

You May Also Like

Primary Sidebar

Recent Posts

  • “aws secretsmanager” Command Examples
  • “aws s3api” Command Examples
  • “aws s3” Command Examples
  • “aws s3 rm” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright