Linux Security

Linux file permissions: chmod and chown

Read and fix permission denied errors without chmod 777 everything like a maniac.

14 min read Beginner Updated 9 Jun 2026

Step-by-step guide

Work through each section in order. Stop when your issue is resolved — you do not need every step for every situation.

Warning

Use a sudo-capable account, keep shell history for audit, and back up critical paths before changing boot, SSH, or package state.

What you will achieve

Read and fix permission denied errors without chmod 777 everything like a maniac.

1) Inspect ownership and mode

ls -l /var/www
namei -l /var/www/html/index.html

2) Apply correct owner/group

sudo chown -R www-data:www-data /var/www/html

3) Apply sane permission defaults

find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;

Related guides

chmod chown linux permissions