Skip to main content
Permission errors are among the most common issues on Unix-based systems, and they are almost always fixable once you understand how the permission model works. Whether you are seeing “Permission denied” when accessing a web directory, an SSH key that is “too open,” or files in a home directory that suddenly became inaccessible, the solution follows directly from reading the permission bits and applying the correct chmod or chown command.

Understanding Unix File Permissions

Every file and directory on a Linux or macOS system has three permission sets — owner, group, and others — each containing three bits: read (r), write (w), and execute (x).

Reading ls -l Output

The ten-character string -rw-r--r-- is read left to right:
Permissions are often expressed as a three-digit octal number:So 644 means owner=rw, group=r, others=r. And 755 means owner=rwx, group=rx, others=rx.
For directories, the execute bit means “traverse” — without it, users cannot cd into the directory or access files within it, even if they have read permission on individual files inside. A directory set to 644 is almost always a mistake.

Step-by-Step Permission Repair

1

Diagnose the Permission Problem

Start by reading the exact error message and inspecting the permissions on the affected file or directory.
namei -l is one of the most useful tools for diagnosing permission failures in nested paths. If any component in the path lacks execute permission for your user, access to the final file will be denied regardless of its own permissions.
2

Fix File Ownership with chown

chown changes the owner and/or group of a file. Use it when a file is owned by the wrong user — a common occurrence after copying files between accounts or running a command as root.
Be careful with recursive chown on system directories. Running sudo chown -R alice /etc would break system authentication. Always double-check the target path before using -R.
Verify the result:
3

Fix File Permissions with chmod

chmod modifies the read, write, and execute bits. Both symbolic and octal notation are accepted.
4

Fix Common Permission Scenarios

Web server processes (typically running as www-data on Debian/Ubuntu or nginx on RHEL) must be able to read your web files — and write to upload directories.
For WordPress and similar CMS installations, the web server user often needs write access to the entire document root during upgrades. After upgrading, tighten permissions back to 644/755 and change ownership back to your deploy user.
5

Use sudo Safely

sudo grants temporary root-level access. Misusing it is a frequent source of incorrect ownership and permissions — files created as root when they should be owned by a service account or regular user.
Avoid running commands like sudo chmod -R 777 / or sudo chown -R root /home — these are destructive and can make the system unbootable or completely open to exploitation. If you find advice online suggesting chmod 777 as a fix, it is masking the real problem rather than solving it.

Quick Reference: Permission Cheat Sheet


Escalation

Check for SELinux or AppArmor policies that override standard POSIX permissions:
Permissions on NFS mounts are governed by the UID/GID mapping between the client and server. If the file owner’s UID on the server does not match a UID on the client, access will be denied regardless of chmod settings. Contact your storage or systems administrator to review the NFS export options or Samba share configuration.
  1. Record the exact error message, the output of ls -la on the affected path, and the output of id for the affected user.
  2. Check journalctl -xe or /var/log/syslog for related audit or denial messages.
  3. Submit a ticket to your systems administrator with the above information. If SELinux or AppArmor is involved, label the ticket accordingly, as policy changes require elevated access.