What it means
Every file has an owner, a group and a mode (rwx for each). To open /srv/app/data/file you also need execute (x) on every directory on the path. Services often run as their own user, so a file that works for root fails for the service.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. Wrong owner after copying files as root
Check:
ls -l /path/to/file
namei -l /path/to/file
ps -o user= -p <pid>
Fix: chown the files to the service user (chown -R app:app /srv/app/data).
2. A directory on the path lacks x for that user
Check:
namei -l /path/to/file
Fix: Add execute on the directory (chmod o+x or g+x), not 777 on everything.
3. Running a script without the execute bit, or from a noexec mount
Check:
ls -l script.sh; findmnt -no OPTIONS --target script.sh
Fix: chmod +x script.sh, or run it with bash script.sh; move it off a noexec mount.
The long version, step by step: sudo echo >> /etc/hosts: Permission denied. Why sudo didn't help
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
- Fix "Permission denied" on Service Dataeasy 6 min
- Permissions for a Whole Treeeasy 6 min
- Three Scripts That Won't Startmedium 8 min
- Undo a chmod -R 777easy 5 min
No account needed for your first tries.
Related errors
- Permission denied (publickey)
The server didn't accept any key the client offered.
- /bin/bash^M: bad interpreter: No such file or directory
The script has Windows line endings, so Linux looks for an interpreter called "bash\r".