Chmod 644 – Linux Permission Guide

What It Means, Explanation, How to Use, When to Use & More

chmod 644

The Standard for Publicly-Readable Files

Apply to a Single File
chmod 644 [filename] Copy
Apply to All Files in a Website (Correct Way — 644 Files + 755 Directories)
find . -type f -exec chmod 644 {} \; Copy
find . -type d -exec chmod 755 {} \; Copy
Verify It Worked
ls -l [filename] Copy
⚠ Don't use chmod -R 644 on a website directory

Running chmod -R 644 . will strip the execute bit from every directory and take your site offline. Use the two find commands above instead. Full explanation below.

What Does chmod 644 Mean?

In Linux, 644 is an octal representation of file system permissions. It's the default permission for most regular files on Linux and the recommended setting for web server content like HTML, CSS, images, and PHP files. The owner can read and write; everyone else can only read.

User (6)

Read + Write
The owner can view and edit the file, but can't execute it as a program.

Group (4)

Read Only
Users in the file's group can view the contents but cannot modify them.

Others (4)

Read Only
Everyone else on the system — including your web server — can read the file.

Why it's the web's default

A web server like Apache or nginx only needs to read your HTML, CSS, and image files to serve them to visitors. It doesn't need to write to them or execute them. 644 gives the server exactly what it needs and nothing more — the principle of least privilege applied to a public website.

Why "644"? How the Numbers Work

Every digit in a chmod code is the sum of three values. Once you know the math, you can decode any permission at a glance.

4
Read (r)
2
Write (w)
1
Execute (x)

Add them together to build any permission digit:

6 = 4 + 2 read + write (no execute)
4 = 4 read only
7 = 4 + 2 + 1 read + write + execute
5 = 4 + 1 read + execute

So 644 reads as: 6 for owner (read + write), 4 for group (read only), 4 for others (read only).

Permission Matrix (rw-r--r--)

Level Read (r) Write (w) Execute (x)
Owner ✔ ✔ ✘
Group ✔ ✘ ✘
Others ✔ ✘ ✘

Numeric vs Symbolic Notation

chmod accepts two equivalent styles. All three commands below produce identical results:

# Numeric (octal) — the one most tutorials show chmod 644 index.html # Symbolic — set exactly these bits chmod u=rw,go=r index.html # Symbolic — grant read to all, then add write for owner chmod a=r,u+w index.html

Letters used in symbolic mode: u = user (owner), g = group, o = others, a = all. Operators: + adds a permission, - removes it, = sets it exactly.

How to Verify It Worked

After running chmod, use ls -l to check the result:

$ chmod 644 index.html $ ls -l -rw-r--r-- 1 alice www-data 2031 Apr 17 14:32 index.html # First character: "-" = file, "d" = directory # Next 3 chars: owner permissions (rw- = read+write, no execute) # Next 3 chars: group permissions (r-- = read only) # Last 3 chars: others permissions (r-- = read only)

If you prefer a numeric check, stat -c "%a %n" filename prints the permission as an octal number — you should see 644 confirmed.

The 644 + 755 Pairing (Essential for Websites)

You almost never apply 644 in isolation. On a real website, 644 comes paired with 755 for directories. This pair is the universal baseline for every shared host, VPS, and CMS on the internet.

644
for files
-rw-r--r--

HTML, CSS, JS, images, PHP scripts, config files. Owner edits, everyone reads.

755
for directories
drwxr-xr-x

Folders need the execute bit to be traversable. Without it, the web server can't enter the folder to reach the files inside.

Why directories need 755, not 644: On a directory, the "execute" permission doesn't mean "run it" — it means "enter it." Set a directory to 644 and you can see its name but not access the contents. Your web server will throw a 403 error trying to reach files inside.

The correct one-two punch for an entire website tree is:

# Files get 644 (readable, not executable) find /var/www/mysite -type f -exec chmod 644 {} \; # Directories get 755 (readable and traversable) find /var/www/mysite -type d -exec chmod 755 {} \;

When to Use chmod 644 (Real Examples)

WordPress file permissions Most common

WordPress officially recommends 644 for all files and 755 for all directories. This is the #1 reason people search for chmod 644. Run these from your WordPress root:

# All directories to 755, all files to 644 find /path/to/wordpress -type d -exec chmod 755 {} \; find /path/to/wordpress -type f -exec chmod 644 {} \; # Then lock down wp-config.php separately (see warning below) chmod 600 /path/to/wordpress/wp-config.php
⚠ Exception: wp-config.php

Your wp-config.php file contains your database password in plain text. On shared hosting, 644 means every other customer on the server can read it. Set it to 600 (owner-only) or 440 as soon as you finish installing WordPress.

Static HTML, CSS, and image files

Any file served by Apache or nginx that the web server only needs to read. This includes your theme's CSS, uploaded images, JavaScript bundles, and HTML pages.

chmod 644 index.html chmod 644 style.css chmod 644 logo.png

Config files in your home directory

Files like .bashrc, .gitconfig, and .htaccess that should be readable by the system but only editable by you.

chmod 644 ~/.bashrc chmod 644 ~/.gitconfig chmod 644 /var/www/mysite/.htaccess

Exception: files containing secrets (.env, .npmrc with auth tokens, SSH authorized_keys) should usually be 600 instead — no one but you should even read them.

The -R 644 Trap (Read This Before You Break Your Site)

This is the single most common way people accidentally take their own website offline: running chmod -R 644 on a whole directory. It seems logical — "I want all my files to be 644, so I'll apply 644 recursively." But it also applies 644 to every directory, which strips the execute bit and makes the folders impossible to enter.

⚠ What happens when you run chmod -R 644 on a website

Apache/nginx tries to enter wp-content/ to serve an image. Permission denied. Every page returns 403 Forbidden or a blank white screen. WordPress admin won't load. File uploads fail. Your site is down until you reverse it.

The fix is to set files and directories separately using find:

# CORRECT — files get 644, directories get 755 find /path/to/target -type f -exec chmod 644 {} \; find /path/to/target -type d -exec chmod 755 {} \; # WRONG — this breaks everything chmod -R 644 /path/to/target

If you already did it: run the two correct find commands above to fix it. Your files will be back to 644 and directories back to 755, and your site will come back online.

Why Are My Files Already 644? (The umask Answer)

A lot of people land on chmod 644 guides not because they're setting 644 but because they noticed their files already are 644 and want to know why. The answer is umask.

Every user on a Linux system has a umask — a "permission mask" that subtracts bits from the default creation mode. Most distributions ship with umask 022, which means:

# Default file mode: 666 (rw-rw-rw-) # Your umask: 022 (----w--w-) # Result for new files: 644 (rw-r--r--) # Default directory mode: 777 (rwxrwxrwx) # Your umask: 022 (----w--w-) # Result for new dirs: 755 (rwxr-xr-x)

That's why you see 644 files and 755 directories appearing everywhere automatically — it's the default environment, not something someone set manually. Check yours with the umask command. Add umask 022 or umask 027 to ~/.bashrc to lock it in.

Changing Permissions Without a Terminal

If you're on shared hosting, you may not have SSH access — but you can still set 644 through your hosting control panel or FTP client.

cPanel File Manager

  1. Log in to cPanel and open File Manager
  2. Navigate to the file (usually inside public_html/)
  3. Right-click the file and choose Change Permissions (or highlight and click the Permissions icon)
  4. Enter 644 in the numeric field, or check: Owner Read/Write, Group Read, Public Read
  5. Click Change Permissions

FileZilla (FTP)

  1. Connect to your server via FileZilla
  2. Right-click the file in the remote pane
  3. Choose File permissions…
  4. Enter 644 in the "Numeric value" field
  5. Click OK

WordPress (whole-site fix)

If you don't have command-line access but need to bulk-fix WordPress permissions, a plugin like All In One WP Security has a "File System Security" tool that will flag and offer to fix any file not set to 644 (and directories not set to 755).

Plesk

  1. Open Files in your Plesk dashboard
  2. Click the checkbox next to the file
  3. Click Change Permissions in the toolbar
  4. Set Owner to Read+Write, Group and Others to Read only

chmod 644 vs Other Common Permissions

Before committing to 644, check whether a neighbor might fit better:

Code Symbolic Typical Use
600 -rw------- Private files only you should read — wp-config.php, .env, SSH private keys, tokens
640 -rw-r----- Owner edits, group reads, nothing for everyone else. Stricter alternative to 644 on VPS / multi-tenant hosts
644 -rw-r--r-- The web's default. HTML, CSS, JS, images, PHP scripts — anything the web server needs to read but not modify
664 -rw-rw-r-- Owner and group can both write. Used on some shared hosts where WordPress runs as a different user than you FTP in as
755 drwxr-xr-x Default for directories. Owner has full access; everyone else can enter and read, but not modify
777 -rwxrwxrwx Avoid. Everyone can read, write, and execute. The "nuclear option" people reach for to fix upload errors — and a common cause of hacked sites

Ownership Matters As Much As Permissions

644 is only half the story. Even with perfect permissions, the wrong owner can leave your web server locked out or give write access to the wrong user.

$ ls -l index.html -rw-r--r-- 1 root root 2031 Apr 17 14:32 index.html # Permissions are correct (644), but root owns it. # The web server (www-data) can still read it — that's fine. # But you (your normal user) cannot edit it without sudo.

The usual ownership pattern for a WordPress or PHP website on a VPS:

# Set your user as owner, web server group as group owner sudo chown -R youruser:www-data /var/www/mysite # Files 644, directories 755 find /var/www/mysite -type f -exec chmod 644 {} \; find /var/www/mysite -type d -exec chmod 755 {} \;

The web server user is typically www-data on Debian/Ubuntu, apache on RHEL/CentOS/Rocky, or nginx on some nginx-only setups. Check with ps aux | grep -E 'apache|nginx|php-fpm'.

Troubleshooting

403 Forbidden after running chmod You set 644 on a directory instead of 755.

Directories need the execute bit to be entered. Run chmod 755 foldername, or fix an entire tree with find /path -type d -exec chmod 755 {} \;

500 Internal Server Error Permissions are too loose on a CGI script or .htaccess file.

Apache rejects PHP or CGI scripts that are group- or world-writable. Make sure scripts are 644 (or 755 for CGI), and .htaccess is 644. A quick fix: chmod 644 .htaccess.

WordPress: "Could not create directory" WordPress (or your FTP user) doesn't own wp-content/, or the directory isn't writable by that user.

This isn't a 644 problem — WordPress needs to write to wp-content/uploads, wp-content/plugins, and wp-content/themes. Check ownership with ls -l wp-content/ and fix with sudo chown -R www-data:www-data wp-content/ (or your deploy user, depending on your setup).

White screen / site won't load after chmod -R 644 You stripped the execute bit from every directory.

Fix with the two-command find recipe: find /path -type d -exec chmod 755 {} \; restores directory traversability, then find /path -type f -exec chmod 644 {} \; keeps files at 644.

Uploads fail / "File uploads are not writable" The uploads directory isn't writable by the user PHP runs as.

Don't "fix" this with chmod 777. Instead, identify your PHP user (usually www-data, apache, or nginx) and make that user the owner or group-owner of wp-content/uploads. Then 755 on the directory is enough.

chmod: Operation not permitted You don't own the file.

Only the file's owner (or root) can change permissions. Use sudo chmod 644 filename if you have sudo, or ask your hosting provider to fix ownership if you're on shared hosting.

Files keep reverting to 664 or 775 after upload Your FTP client or server umask is rewriting permissions on upload.

In FileZilla: Edit → Settings → Transfers → FTP: File Types → Default transfer type, and check the "Preserve timestamps / permissions" options. On the server side, the FTP/SFTP daemon may have a umask setting in its config. Some shared hosts set files to 664 by design — that's usually fine.

The Universal Website Permissions Reset

If you've been poking at permissions and everything's a mess, this is the recipe to bring things back to a known-good state for almost any PHP/static website:

cd /path/to/your/website # 1. Set ownership (replace "youruser" and adjust web group for your OS) sudo chown -R youruser:www-data . # 2. Directories to 755, files to 644 find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; # 3. Lock down sensitive files chmod 600 wp-config.php # WordPress chmod 600 .env # Laravel, Node apps, etc. chmod 644 .htaccess # Apache rewrite rules

After running this, verify with ls -la and try loading the site in a browser. 9 times out of 10 this fixes whatever was broken.

Frequently Asked Questions

Should I use 644 on a directory?

Almost never. Directories need the execute bit (1) to be entered — without it, nothing inside the folder is reachable. Use 755 for directories and 644 for the files inside them.

What's the difference between 644 and 664?

The middle digit. 644 gives the group read-only access; 664 gives the group read + write. Use 664 when multiple users in the same group (e.g., you and WordPress's PHP process) both need to edit the same files. On many shared hosts this is actually required for plugin installs and auto-updates to work.

Is 644 safe for wp-config.php?

Not ideal. wp-config.php holds your database credentials in plain text. 644 means any other user on the server (other customers on shared hosting, for example) can read it. Set it to 600 or 440 after WordPress finishes installing.

Why did my files all become 644 by themselves?

That's your umask. Most Linux systems default to umask 022, which creates new files as 644 and new directories as 755. You didn't set it — the system did. Run umask to see your current value.

What's the symbolic equivalent of 644?

-rw-r--r-- when viewed with ls -l. To set it symbolically: chmod u=rw,go=r filename.

Can I use chmod 644 without sudo?

Yes — for files you own. Only the file's owner or root can change permissions. Files owned by root, www-data, or another user require sudo chmod 644 filename.

What's better for web files: 644 or 640?

On a single-user VPS or shared hosting where you control everything: 644 is simpler and works everywhere. On a multi-tenant VPS where other customers share the box: 640 is stricter, giving the web server group read access while locking out everyone else entirely. 644 is the common baseline; 640 is the hardened version.

My file is 644 but the web server still can't read it. Why?

Either ownership is wrong (check with ls -l — is the group something the web server can access?), or a parent directory is missing its execute bit, blocking traversal. Walk up the directory tree and make sure every folder from root down to your file is at least 755 (or has the web server's group in the group slot with read+execute).

–

Scroll to Top