Setting proper file permissions before committing files

Last updated on
16 September 2020

The Drupal project aims for consistency and correct values by default. The final permissions suggested for files are covered at great length in the security handbook. For files checked into the git repository on drupal.org, the standard is set forth by core of what permissions are appropriate.

  • Most files should be 644 or -rw-r--r--
  • All directories should be 755 or drwxr-xr-x
  • Files that are intended to be run at the command line should have the executable bit set meaning 755 or -rwxr-xr-x

Another resource about the proper permissions is Drupal.StackExchange: What are the recommended directory permissions?. Files committed to the repository on drupal.org should use permissions that match the ideal case as closely as possible.

Commands

On Linux/Unix/Mac command line, use the chmod command to change file permissions.

On Windows, even with a Linux-like command window, changing file permissions will not work. As a work-around, you can use Git commands like this:

# Example: Remove the executable bit:
 git update-index --chmod=-x path/to/file.ext

Tags

Help improve this page

Page status: No known problems

You can: