chmod 644 vs 664
| Property | chmod 644 | chmod 664 |
|---|---|---|
| Octal | 644 |
664 |
| Symbolic | rw-r--r-- |
rw-rw-r-- |
| Owner | read/write | read/write |
| Group | read | read/write |
| Others | read | read |
| Risk Level | Low Risk | Moderate |
| Typical Use | Web server assets including HTML, CSS, JavaScript, and PHP files | Collaborative source files and shared git checkouts in multi-user teams |
Key Difference
- Group: chmod 644 grants read (4), while chmod 664 grants read/write (6).
Which Should You Use?
Choosing between chmod 644 and chmod 664 depends on whether team members sharing the same Unix group need write access to a file. Under mode 644, the file owner has read and write privileges, while group members and all other system users only receive read access. This is the universal default on most Linux distributions for configuration files, source code, and static web assets. Under mode 664, both the owner and anyone in the file group can edit the file. This setup is common in collaborative environments, shared Git checkouts, and multi-tenant development servers where developers belong to a shared group like "developers" or "staff". For single-user servers or cloud virtual machines where only one human logs in, 644 provides better isolation and prevents accidental cross-service overwrites.
Frequently Asked Questions
Is 644 more secure than 664?
Yes. Mode 644 prevents any process or user other than the file owner from editing the file. If an unprivileged service account in the group is compromised, mode 644 stops it from modifying your files.
Can I convert 644 to 664?
Yes. You can grant group write access with "chmod g+w filename" or set the octal mode directly with "chmod 664 filename". To revert back, run "chmod g-w filename".
Which is better for web servers?
Mode 644 is standard and recommended for web servers. It allows the web server daemon to read HTML and PHP files while ensuring that only the application owner account can edit or update the source code.
Related Permissions & Comparisons
Read in-depth breakdowns for chmod 644 (rw-r--r--) and chmod 664 (rw-rw-r--), or browse other permission comparisons: