Linux (13: Permission denied) ; hack !
Having a bad day with a `(13: Permission denied)` while all chmod and chown look right?!

This is a structured check list on how to figure permission issues on your Linux box given you have a (13: Permission denied) or something similar, and you have checked chown and chmod multiple times.
Basics
- Temporarily give maximum permission
777
and try. Please note if this does not work, please revert to original. Note it! - If you don’t remember original; Typically default permissions
755
for folder and644
for files is safe.
Background Process
- Identify the process running user. Typically
ps -ef | grep <service>
. Ensure the folder/files are under the same ownership. systemctl cat <service name>
: Can chooseUser=
orGroup=
fields more powerful (like root). And revert it to default state after knowing it works.- One can launch background processes in fork mode and under the correct user using: `sudo` su — root -c <command>`
Services like
nginx
give `HTTP 403` andmongod
cant seem to launch properly viasystemctl
OR givePermission Denied
issues in error logs.Example error log: <path> is forbidden (13: Permission denied)
SELinux
If you have tried all other methods; this is the main reason you are probably here.
If you are not expert and can’t reason with the wierd permission issues;
Just disable SELinux
Can also try specific settings, for nginx
example: setsebool -P httpd_can_network_connect 1
Enforce or not
getenforce
Overall SELinux Status
sestatus
Full SELinux configs
Restart the server post changes.
vi /etc/selinux/config
Temporary Disable/Enable
setenforce Enforcing | Permissive