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.
For example:
getent group developers
This will display information about the developers
group if it was created successfully.