Technical Deep-Dive: Chmod 644 (-rw-r--r--)
Bitwise binary arithmetic, POSIX DAC rules, and security guidelines for production servers.
1. Binary Calculation Mechanics
POSIX file systems represent permissions in triplets of binary bits where Read is 4 (2^2), Write is 2 (2^1), and Execute is 1 (2^0). In chmod 644, each digit computes as:
- • Owner: 6 (Read Write )
- • Group: 4 (Read )
- • Others: 4 (Read )
2. Practical CLI Execution
Apply this configuration to files or directories with the standard Linux terminal commands:
Frequently Asked Questions
Why should web server files be set to chmod 644 instead of 755 or 777?
Static web assets (HTML, images, CSS, frontend JavaScript) should never have execute bits enabled. Setting them to 644 ensures web daemons like Nginx can read and serve them to HTTP clients, while malicious web uploads or local compromised processes cannot execute them as executable binaries.
How do I set chmod 644 on all files without changing directory permissions?
Use the Linux find utility: find /var/www/html -type f -exec chmod 644 {} +. This restricts the change strictly to regular files, keeping directory execute bits intact.
Can the file owner execute a file with chmod 644?
No. Because the execute bit (x) is 0 for the owner (6 = 4+2+0), even the file creator cannot run it directly from the terminal without explicitly prefixing the interpreter (e.g., bash script.sh or python script.py) or running chmod +x.