A developer accidentally ran `chmod -R 777 /var/www`. How do you restore sane permissions?
BeginnerScenarioUsers, groups and access control
Answer
Situation read → Reset directories and files separately.
What I'd do →
sudo chown -R www-data:www-data /var/www
sudo find /var/www -type d -exec chmod 755 {} +
sudo find /var/www -type f -exec chmod 644 {} +
Then re-apply exceptions such as writable upload dirs (775) or executable scripts, and check config files holding secrets (640).
Why → Directories need x to be entered; files usually should not be executable.
Interview tip → If the files came from a package, rpm --setperms pkg or reinstalling restores the original modes.
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?BeginnerThree 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?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?Beginner