Three teams share one server and each needs a project directory only its members can write to, with new files staying group-owned. How do you set it up?
BeginnerScenarioUsers, groups and access control
Answer
Situation read → Classic group-shared directory with the setgid bit.
What I'd do →
- Create groups
team-a,team-b,team-cand add members withusermod -aG. - Create directories and set ownership:
sudo mkdir -p /srv/projects/{team-a,team-b,team-c}
for t in team-a team-b team-c; do
sudo chown root:$t /srv/projects/$t
sudo chmod 2770 /srv/projects/$t
done
- Set
umask 002for those users (in/etc/profile.d/) so files are group-writable.
Why → The setgid bit (2 in 2770) makes new files inherit the directory's group instead of the creator's primary group.
Interview tip → Mention that users must log out and back in for new group membership to apply.
More on Users, groups and access control
You need to onboard 50 new developers onto a shared build server, each with their own account and SSH key. How do you do it?BeginnerA junior engineer needs to restart nginx but must not get full root. How do you grant that?BeginnerAn engineer leaves the company today. What do you do with their Linux account on 30 servers?BeginnerA service account for a backup tool must exist on every server but nobody should be able to log in as it. How do you create it?BeginnerYour security team requires passwords to expire every 90 days for human users only. How do you implement it?BeginnerTwo developers need read access to `/var/log/app/` without being added to the `adm` or root group. How?Intermediate