Thursday, January 23, 2025
HomeProgrammingHow to Create a new group in Linux | groupadd command

How to Create a new group in Linux | groupadd command

To create a new group in Linux, you can use the groupadd command. Here’s the basic syntax:

sudo groupadd <groupname>

Where <groupname> is the name of the group you want to create.

Example:

To create a new group named developers, you would run:

sudo groupadd developers

Options:

  • -g GID: Specify a custom group ID (GID).

    Example:

    sudo groupadd -g 1050 devgroup
    
  • -f: This forces the command to exit with success if the group already exists (won’t create a duplicate).

    Example:

    sudo groupadd -f developers
    

After running the groupadd command, the new group will be created, and you can verify it by checking the /etc/group file or by using the getent group command.

See also  What Is An Index In SQL?

For example:

getent group developers

This will display information about the developers group if it was created successfully.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x