What does chmod do?
chmod (change mode) sets who can read, write or run a file or folder on Linux, macOS and other Unix systems. Every file has three groups of users: the owner, the group and others (everyone else). Each group gets its own mix of three permissions: read, write and execute.
How the octal numbers add up
Each permission has a value: read is 4, write is 2 and execute is 1. Add the ones you want for each group and you get one digit. Three groups give three digits.
- 7 = 4 + 2 + 1 = read, write, execute
- 6 = 4 + 2 = read, write
- 5 = 4 + 1 = read, execute
- 4 = read only, 0 = nothing
So 755 means owner 7 (full), group 5 (read and execute), others 5 (read and execute). The same mode written as letters is rwxr-xr-x.
Common chmod values
| Number | Letters | Typical use |
|---|---|---|
| 644 | rw-r--r-- | Normal files: you edit, everyone can read |
| 755 | rwxr-xr-x | Folders and scripts or programs |
| 600 | rw------- | Private keys, .env files, secrets |
| 700 | rwx------ | Private folders, such as ~/.ssh |
| 775 | rwxrwxr-x | Shared folders for a trusted group |
| 664 | rw-rw-r-- | Shared files for a trusted group |
| 777 | rwxrwxrwx | Avoid. Everyone can change it |
What execute means on a directory
On a file, execute means you can run it as a program. On a directory it means you can enter it and reach what is inside. Read on a directory lets you list the names, and write lets you add, rename or delete entries. A folder with r-- but no x is almost useless, which is why folders are normally 755 or 700, not 644.
Setuid, setgid and the sticky bit
A fourth digit in front sets special bits: setuid is 4, setgid is 2 and sticky is 1. 4755 is rwsr-xr-x.
- Setuid (4): the program runs as its owner, not as the user who started it. Shows as
sin the owner execute spot. A capitalSmeans setuid is set but execute is not. - Setgid (2): a program runs as its group. On a directory, new files inherit the folder's group. Shows as
sin the group spot, for example2750isrwxr-s---. - Sticky bit (1): on a directory, only a file's owner (or root) can delete or rename it. This is why
/tmpis1777,rwxrwxrwt. Shows ast, orTif others lack execute.
WordPress file permissions
As general guidance, WordPress folders are usually 755 and files 644. Keep wp-config.php tighter, at 600 or 640, because it holds your database password. The user running the web server must be able to read the files, so if the owner is wrong, fix it with chown first. Avoid 777 anywhere. To set them in one go from your site folder:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 600 wp-config.php
chmod vs chown
chmod changes what an owner, group and others may do; chown changes who the owner and group are.
How to read ls -l
Run ls -l and each line starts with ten characters, like -rwxr-xr-x. The first is the type: - for a file, d for a directory, l for a link. The next nine are owner, group and others, three each. Paste them in the Symbolic box above to get the octal number.
Using chmod on your own server
On a RapidServer Linux VPS you get full root access, so chmod and chown work on every file you manage. Connect over SSH (see SSH kya hai), and new to the system? Start with Linux kya hai. VPS plans start at ₹581/mo plus 18% GST. More free tools are on the calculators page.
KVM VPS in Mumbai or Delhi NCR with full root, NVMe storage and daily backups.
VPS plans dekhiyeChmod questions
What does chmod 755 mean?+
What is the difference between chmod 644 and 755?+
rw-r--r--) is for ordinary files that are read, not run. 755 (rwxr-xr-x) adds execute so a script can run and a folder can be opened.Is chmod 777 safe?+
How do I chmod a directory and everything inside it?+
chmod -R 755 folder. Be careful: it gives files the execute bit as well. To set folders and files differently, use the two find commands in the WordPress section above.What does the sticky bit do?+
chmod +t folder or the leading 1, as in chmod 1777 folder.What does rwxr-xr-x mean?+
Why do I get "Operation not permitted" when I run chmod?+
ls -l, then run the command as that user or with sudo.