chmod 755 vs 644

Property chmod 755 chmod 644
Octal 755 644
Symbolic rwxr-xr-x rw-r--r--
Owner read/write/execute read/write
Group read/execute read
Others read/execute read
Risk Level Low Risk Low Risk
Typical Use Standard Linux directories and folder structures Web server assets including HTML, CSS, JavaScript, and PHP files
Advertisement

Key Difference

Which Should You Use?

The fundamental rule in Linux administration is simple: use chmod 755 for directories and executable scripts, and use chmod 644 for regular files. A directory requires execute permission (x) so that operating system processes and users can traverse inside, list files, and access its child nodes. Without execute permission on a directory, web servers like Nginx or Apache cannot serve any documents inside it, leading to 403 Forbidden errors. Conversely, regular web files like HTML pages, CSS stylesheets, images, and PHP scripts should never have execute permissions unless they are standalone command-line executables. Setting regular files to 644 allows the owner to read and modify them while permitting the web server to read them safely. Never run a blanket recursive "chmod -R 755" across an entire project, as this dangerously marks every text and image file as an executable program.

Advertisement

Frequently Asked Questions

Is 644 more secure than 755?

Yes, 644 is more secure for non-executable files because it strips the execute bit. Marking ordinary text, image, or configuration files with 755 allows them to be executed as binaries or scripts if an attacker finds an entry point on your server.

Can I convert 755 to 644?

Yes. To convert files specifically from 755 to 644 without breaking directory traversal, use the find utility: "find /path/to/folder -type f -exec chmod 644 {} +". This targets only regular files while preserving 755 on directories.

Which is better for web servers?

Web servers require both: directories must be set to 755 so the web server daemon can enter and resolve paths, while web files (HTML, CSS, PHP) must be set to 644 so the server can read and serve them.

Related Permissions & Comparisons

Read in-depth breakdowns for chmod 755 (rwxr-xr-x) and chmod 644 (rw-r--r--), or browse other permission comparisons:

Advertisement