Deploy Fails with Permission Denied. chmod 777 Everything?
A deploy fails with permission errors and a teammate wants to chmod -R 777 the app directory so it never happens again. Defend fixing the actual ownership mismatch instead.
Answer key reviewed by Branko Petric
Read first: Linux File Permissions
Your decision
A deploy to a Linux VM fails with 'Permission denied' when the app tries to write to its data directory. A teammate says just run chmod -R 777 on the whole app directory so permissions can never break a deploy again. What do you do, and why?
The situation
A routine release to a single Linux VM fails. The app starts, then crashes with 'Permission denied' writing to /srv/app/data/uploads. ls -l shows the directory owned by root, while the service runs as the appuser account. This is the second time this month a deploy has died on permissions.
Context
The app is deployed by a CI job that rsyncs files onto the box over SSH and restarts the systemd service. Last month someone "fixed" a similar error by hand and it came back with this release. A teammate in chat says: just chmod -R 777 /srv/app and we will never see this class of error again.
Related challenges
- Disk Is at 100% and the App Is Down. rm -rf?
A server is out of disk and the app is down. A teammate wants to rm -rf the logs to free space fast. Defend what you actually do first.
- The Fix Is One Line in /etc. Just SSH In and Edit It?
Prod is degraded by one wrong sysctl value in /etc on an Ansible-managed fleet. A teammate wants to hand-edit each box now and codify it later. Defend the call.
- The Box Keeps OOM-Killing. Just Add a Huge Swapfile?
A latency-sensitive service keeps getting OOM-killed and a teammate wants to add 16GB of swap and crank swappiness. Defend what you actually do instead.
- You Pushed AWS Keys to a Public Repo
Live cloud keys just landed in a public GitHub repo. A teammate says delete the file and force-push. Defend what you do first.