Skip to content

Instantly share code, notes, and snippets.

@alihalabyah
Created February 19, 2017 13:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alihalabyah/e9d5cd077efb4b62cdd40bf4cf75c8ac to your computer and use it in GitHub Desktop.
Save alihalabyah/e9d5cd077efb4b62cdd40bf4cf75c8ac to your computer and use it in GitHub Desktop.
Magento 2 Reset Directories and Files Permissions
find . -type f -exec chmod 644 {} \; // 644 permission for files
find . -type d -exec chmod 755 {} \; // 755 permission for directory
find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod -R g+w *
@dambrogia
Copy link

dambrogia commented Nov 5, 2019

If you use the +; at the end of the command rather than \; it will process all the files at once rather than one by one.

\; is the same as chmod 644 file1.txt; chmod 644 file2.txt; and +; is the same as chmod 644 file1.txt file2.text.

You will see major performance increases.

Edit:

Also, you don't need the final chmod command on line 9 and you shouldn't resort to 777 permissions.
These will work better:

find . -type f -exec chmod 644 {} +;
find . -type d -exec chmod 755 {} +;
find app/etc generated pub/static var -type d -exec chmod 775 {} +;
find app/etc generated pub/static var -type f -exec chmod 664 {} +;
chmod u+x bin/magento
# You might need to adjust apache/nginx permissions as well, YMMV
chown <my-user>:<my-group> . -R

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment