Linux (13: Permission denied) ; hack !

arjun dhar
2 min readMay 22, 2020

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 permissions755 for folder and 644 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 choose User= or Group= 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` and mongod cant seem to launch properly via systemctl OR give Permission 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 nginxexample: 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

--

--

arjun dhar

Software development enthusiast since I was 8 yrs old. Love communicating on anything regarding innovation, community development … ∞