groupadd
create a groupgroupadd adds a group to the system. A group is a named set of users who can be granted access together: create it, add people to it, and hand a directory to the group instead of to each person.
Three steps to a shared directory: groupadd, usermod -aG, chgrp.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
The group exists but is empty until members are added.
Name, a password placeholder, the group id, and the list of members.
The directory now belongs to the developers group.
Shown as the s in rws. Files created inside inherit the developers group, so everything in the directory stays shared.
Switches
A switch changes how the command behaves. These are the ones used day to day; man groupadd lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-g GID- Use this group id.
-r- Create a system group, with a low id.
-f- Exit successfully if the group already exists.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo gpasswd -a ravi developersAdds a user to a group.
sudo gpasswd -d ravi developersRemoves a user from a group.
sudo groupdel developersDeletes a group.
cat /etc/group | cut -d: -f1Lists every group on the system.
In cybersecurity
Groups are how access is granted without handing out root.
A shared directory owned by a group and closed to others is the right answer. chmod 777 is the wrong one.
People change teams. A group whose membership is never reviewed slowly comes to include everyone.
They keep shared files in the right group, but check that only intended members can write there — whoever can, can alter everyone’s files.