UnderHost
Knowledgebase Docs

Permission denied errors-chmod, chown, and fixes

Fix "Permission denied" errors with chmod, chown, and file ownership on Linux/VPS servers.

On this page

Permission denied errors occur when a user doesn't have read, write, or execute rights to a file or directory. On Linux, each file has owner, group, and "other" permissions.

Fix with chmod

Change file permissions:

chmod 644 file.txt       # owner can read/write, others read-only
chmod 755 directory/     # owner has full control, others can read/execute
chmod 777 file.php       # everyone can read/write/execute (not recommended)

Fix with chown

Change file owner:

chown user:group file.txt        # change owner and group
chown -R user:group directory/   # recursively change all files

Common fixes

  • Can't read file: chmod 644 filename
  • Can't write to directory: chmod 755 dirname/
  • Web server can't access: chown www-data:www-data file
  • PHP can't write (uploads): chmod 755 /path/to/uploads
  • Can't execute script: chmod 755 script.sh
Never use 777

chmod 777 is a security risk. Only use it temporarily for debugging, then set proper permissions.

Related: Manage your VPS

Was this article helpful?

Still troubleshooting?

Use UnderHost tools for quick checks, or open a support ticket when the issue needs account or server access.

Related articles

Back to Troubleshooting