Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Fix Permission Denied Errors in Linux

Permission denied is almost always wrong owner, mode or user. Do not jump to chmod 777.

Steps

  1. Inspect owner and permissions:

    ls -la /path/to/resource
    namei -l /path/to/resource
  2. Fix ownership (web example) or your user:

    sudo chown -R www-data:www-data /var/www/project
    sudo chown user:user /home/user/file
  3. Set sensible modes (dirs 755, files 644; scripts +x):

    sudo find /var/www/project -type d -exec chmod 755 {} \;
    sudo find /var/www/project -type f -exec chmod 644 {} \;
    chmod u+x ./script.sh
  4. For SSH/SFTP, check ~/.ssh (700) and authorized_keys (600):

    chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys

Tips

  • Run the command as the same user as the service (www-data, git, etc.).
  • On mounted disks, check noexec or NFS root_squash.

ext step

Manage permissions on your own VPS: Deploy your Cloud VPS.

Related guides