File Permissions and chmod Explained

Category: FTP & File Management · Updated 2026-11-02

File permissions are the rules, built into Linux and other Unix-like systems, that decide who can read, write or execute a file or folder. Each file has three permission sets, for the owner, the group and everyone else, and the chmod command is how you view or change them, either with letters like u+x or numbers like 755.

How Unix file permissions work

Every file and folder on a Linux server has three permission categories: owner (the user who created it or was assigned it), group (a set of users sharing access), and other (everyone else with access to the system). Each category can have three types of access:

  • r (read) — view the file's contents, or list a folder's contents.
  • w (write) — modify or delete the file, or add/remove files inside a folder.
  • x (execute) — run the file as a program or script, or enter ("cd" into) a folder.

Running ls -l in a terminal shows permissions as a 10-character string, such as -rwxr-xr--. The first character marks the type (- for a file, d for a directory), and the next nine are three groups of rwx for owner, group, and other.

Numeric (octal) permission codes

chmod also accepts a three-digit numeric shorthand. Each digit adds up read (4), write (2) and execute (1) for one category:

NumberPermissionsMeaning
7rwxread + write + execute
6rw-read + write
5r-xread + execute
4r--read only
0---no access

So chmod 644 file.php gives the owner read and write, while group and other get read only. chmod 755 folder gives the owner full control and lets everyone else read and enter the folder but not change it. These two combinations cover most web files: 644 for regular files, 755 for folders and scripts that need to run.

Using the chmod command

On a server with SSH access, chmod runs directly in the terminal:

chmod 644 index.php
chmod 755 cgi-bin
chmod -R 755 scripts/
chmod u+x deploy.sh

The -R flag applies the change recursively to every file and subfolder. The symbolic form (u+x, g-w, o=r) adjusts one category at a time instead of resetting all three. If you only have FTP access, most FTP clients let you right-click a file, choose "File permissions" or "chmod", and enter the same three-digit number through a checkbox grid.

Common permission mistakes

A few mistakes come up constantly on shared and VPS hosting:

  • Using 777 as a quick fix. This gives write access to everyone, including other accounts on a shared server or any script that finds a way in. It is almost never the correct fix and is a common cause of site compromises.
  • Wrong ownership instead of wrong permissions. If a file is owned by the wrong user, chmod alone won't fix access; the server needs chown to change the owner or group first.
  • Config files left too open. Files like wp-config.php that hold database passwords should usually be 640 or 600, not 644, where the hosting setup allows it.

Frequently asked questions

What do the numbers in chmod 755 mean?

Each digit is a sum of read (4), write (2) and execute (1) for owner, group and other in that order. 755 means the owner gets read+write+execute (7), while group and other each get read+execute (5).

What is the difference between chmod 644 and 755?

644 gives the owner read and write but no execute, and gives everyone else read only — the standard setting for regular files. 755 adds execute for everyone, which is needed for folders and for scripts that must run.

Why shouldn’t I use chmod 777?

777 lets any user or process on the system read, write and execute the file, which removes the protection permissions are meant to provide. It's a common root cause of hacked websites on shared servers.

How do I change file permissions over FTP?

Most FTP clients let you right-click a file or folder and choose an option like "File permissions" or "chmod", then enter a numeric code such as 644 or 755 in the dialog that appears.

What permissions should wp-config.php have?

600 or 640 is safer than the default 644, since the file contains database credentials; the exact minimum depends on how your hosting account's file ownership is set up.

What does chown do differently from chmod?

chmod changes what actions (read, write, execute) are allowed; chown changes who owns the file, meaning which user and group account it belongs to. Fixing access sometimes requires both.

Related topics