Linux File Permissions: A chmod and chown Guide
How to read and change Linux file permissions: rwx, 755 and 644, chmod and chown, the right permissions for sites and SSH, and Permission denied errors.

Contents
- Reading permissions: ls -l
- What do r, w and x mean?
- Numeric permissions: 755, 644, 600
- chmod: changing permissions
- chown: changing the file owner
- The right permissions for website files
- Never use chmod 777
- Permissions for SSH files
- Fixing the "Permission denied" error
- Special permissions: setuid, setgid and the sticky bit
- File permissions on Nodesty servers
Linux file permissions decide who can read, write and execute every file and folder on a server. Most "Permission denied" errors, files that won't upload, scripts that won't run and rejected SSH keys come down to the wrong permissions or the wrong file owner. Once you learn to read permissions, you can fix most of these problems with a few commands.
This guide covers how to read permissions, the chmod and chown commands, the right permissions for websites and SSH files, and how to fix the "Permission denied" error.
Reading permissions: ls -l
After connecting to your server over SSH, run this to see the permissions of the files in a folder:
ls -l
The output looks like this:
-rw-r--r-- 1 alex www-data 4120 Oct 29 10:12 index.php
drwxr-xr-x 3 alex www-data 4096 Oct 29 10:10 uploads
The first column shows the permissions:
- The first character:
-for a regular file,dfor a folder,lfor a symbolic link. - The next three characters: The permissions of the file's owner (user).
- The middle three characters: The group's permissions.
- The last three characters: Everyone else's (others) permissions.
The third and fourth columns show the file's owner and group; in the example above, the owner is alex and the group is www-data.
What do r, w and x mean?
| Letter | On a file | On a folder |
|---|---|---|
r | Read the contents | List the files inside |
w | Change the contents | Create, delete and rename files inside |
x | Run it as a program or script | Enter the folder and access the files inside |
The x permission on folders is easy to overlook: if a folder doesn't have x, the files inside can't be accessed, whatever their own permissions are.
Numeric permissions: 755, 644, 600
Each permission maps to a number: r = 4, w = 2, x = 1. These numbers are added up for the owner, the group and others:
| Number | In letters | Meaning | Where it's used |
|---|---|---|---|
755 | rwxr-xr-x | Owner can do everything, others read and enter | Folders, executable scripts |
644 | rw-r--r-- | Owner reads and writes, others only read | Website files |
700 | rwx------ | Only the owner has access | Private folders such as ~/.ssh |
600 | rw------- | Only the owner reads and writes | Password and key files |
640 | rw-r----- | Owner reads and writes, the group only reads | Config files the application needs to read |
For example, 7 = 4 + 2 + 1 (rwx), 5 = 4 + 1 (r-x), 6 = 4 + 2 (rw-).
chmod: changing permissions
chmod 644 index.php
chmod 755 uploads
chmod 600 .env
You can also use letters. u means the owner, g the group, o others and a everyone:
chmod u+x deploy.sh # give the owner execute permission
chmod g-w config.php # remove write permission from the group
chmod o-rwx backups # remove all permissions from others
You can use -R to change the permissions of a folder together with its contents, but chmod -R 755 makes files executable too. To give folders and files different permissions, find is the better tool:
find /var/www/site -type d -exec chmod 755 {} \;
find /var/www/site -type f -exec chmod 644 {} \;
chown: changing the file owner
sudo chown alex index.php
sudo chown alex:www-data index.php
sudo chown -R alex:www-data /var/www/site
The user:group format changes the owner and the group together. Most permission problems on websites come from files belonging to root, for example when you copy files with sudo or run git clone as root.
The right permissions for website files
On Ubuntu and Debian, Nginx and Apache run as the www-data user; on AlmaLinux, Nginx runs as nginx and Apache as apache. A common and safe layout on your own VPS:
- Files are owned by your user, with the web server's group as the group:
chown -R alex:www-data /var/www/site - Folders are
755and files are644. - Folders the application needs to write to (
wp-content/uploadsin WordPress,storageandbootstrap/cachein Laravel) get group write permission:chmod -R 775 storage - Config files that contain the database password (
wp-config.php,.env) are640or600.
If you run PHP-FPM as your own user, you don't need group write permission; the files already belong to the user PHP runs as. We cover installing Laravel in our How to deploy Laravel guide and Nginx in our How to install Nginx guide.
On shared web hosting, PHP runs as your account's user, so 755 for folders and 644 for files is enough. You can change permissions from the cPanel or DirectAdmin file manager or from your FTP client; the details are in our FTP vs SFTP article.
Never use chmod 777
777 means every user and every process on the server can change that file. A single compromised plugin on a website can write malicious code into those files. If something only works with 777, the problem isn't the permission but the file's owner; use chown to give the file to the right user. We cover what to do with a site that has been attacked in our Website hacked? What to do guide.
Permissions for SSH files
SSH refuses to use key files if their permissions are too open:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
The private key file on your own computer (~/.ssh/id_ed25519) should also be 600. Also check that the folder and the file belong to your user; an authorized_keys file created as root breaks key-based login.
Fixing the "Permission denied" error
- Check the file's owner and permissions:
ls -l file - Check every folder along the path. If a single folder in between doesn't have the
xpermission, the file can't be accessed.namei -lshows the whole path at once:
namei -l /var/www/site/public/index.php
- Find out which user the process runs as. The web server, PHP-FPM or a systemd service may be running as a different user from you:
ps -eo user,comm | grep -E 'nginx|php|apache' - Fix the owner or the permission; don't use
777.
We've collected the basic Linux commands in our Linux commands article.
Special permissions: setuid, setgid and the sticky bit
Sometimes you'll come across four-digit permissions:
- Sticky bit (
1777): In folders everyone can write to, such as/tmp, it makes sure users can only delete their own files. - setgid (
2775) on folders: New files created in the folder get the folder's group. It's useful when several users work in the same project folder. - setuid: Makes a program run with the permissions of the file's owner rather than the user running it. It's used by system programs such as
passwd; don't set it on your own files.
File permissions on Nodesty servers
On Nodesty AMD Ryzen 9 9950X VPS and AMD EPYC 7763 VPS plans, you have full root access to set file owners and permissions however you like. If you'd rather not manage a server, PHP runs as your account's user on our web hosting plans; you can change permissions in a few clicks from the cPanel or DirectAdmin file manager.
Frequently Asked Questions
What do 755 and 644 mean?
755 means the owner can read, write and execute the file, while the group and everyone else can only read and execute it; it's the usual permission for folders. 644 means the owner can read and write, while everyone else can only read; it's the right permission for ordinary files on a website.
Why shouldn't I use chmod 777?
777 means every user and every process on the server can change that file. A single compromised plugin on a website can write malicious code into those files. If something doesn't work without 777, the problem isn't the permission but the file's owner; use chown to give the file to the right user.
What's the difference between chmod and chown?
chmod changes who can do what with a file, meaning the read, write and execute permissions. chown changes the file's owner and group. Most permission problems on websites come not from the wrong permissions but from files belonging to the wrong user.
How do I change file permissions on web hosting?
In the cPanel and DirectAdmin file managers, you can right-click a file and change its permissions, or you can enter the permission value in the file properties in your FTP client. On shared hosting, 755 for folders and 644 for files is usually right.
Why is my SSH key being rejected?
If the permissions on key files are too open, SSH treats them as insecure and won't use them. On the server, make sure the ~/.ssh folder is 700, the authorized_keys file is 600 and both belong to your user. The private key file on your own computer should also be 600.
I can't change a file without sudo. What should I do?
The file may belong to root or another user. Use chown to give files that you or your application need to change regularly to the relevant user. Keep editing system files with sudo; don't hand them over to a regular user.
About the author
Nodesty Team · Infrastructure & Support
The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.
Related articles

Linux Timezone and NTP: A Server Time Setup Guide
How to set the timezone and NTP on a Linux server: timedatectl, UTC or local time, chrony and timesyncd, cron, logs, 2FA codes and Windows Server.

How to Install Ollama: Run AI Models on Your Own Server
How to install Ollama and run AI models on your own server: setup, choosing a model and RAM, using the API, Open WebUI, secure access and CPU usage.

How to Install WordPress with Docker Compose
How to install WordPress with Docker Compose: MariaDB and WordPress containers, passwords in .env, Nginx and SSL, upload limits, backups and updates.