the file /etc/group will contain the group information
groupadd student
groupadd assigns the group ID automatically which is graeater than id of other groups.we can create id s using the -g or -gid
groupadd student -g GID
the groupid must be unique and non negative .-o option allows to create duplicate or non unique ids.
groupadd -o student -f -GID
by using -r or --system we can create system group the group id are between 100 to 999
groupadd -r student
--f or -- force option forces groupadd command to exit status if the group already exists
groupadd -f student
-p or --password allows groupadd command to specfy the encrypted password to the group
groupadd student -p nuhdf
- k option is used to specify the group id between the given specified limits
groupadd -K GID_MIN=100 -K GID_MAX=499 student
Explanation:
Creates a group named developers.
sudo groupadd developers
Creates a group named testers with the GID 1050.
sudo groupadd -g 1050 testers
Creates a system group named sysadmins (system groups have GIDs below 1000).
sudo groupadd -r sysadmins
developers:x:1001:
Explanation:
Checks if the developers group exists in the system.
getent group developers
Explanation:
Displays all existing groups and their details.
cat /etc/group
or
getent group
Explanation:
Adds the user alice to the developers group.
sudo usermod -aG developers alice
Explanation:
Adds user bob to developers, testers, and sysadmins groups.
sudo usermod -aG developers,testers,sysadmins bob
Explanation:
Deletes the testers group.
sudo groupdel testers
Explanation:
Changes the GID of the developers group to 2000.
sudo groupmod -g 2000 developers
Explanation:
Renames the developers group to eng_team.
sudo groupmod -n eng_team developers
Creates a new user group.
sudo groupadd developers