Magento – Reset Filepermissions

To reset filepermissions of Magento, you can run these commands on shell from within the Magento root folder:

$> #for magento 1.5+
$> find . -type f -exec chmod 644 {} \;
$> find . -type d -exec chmod 755 {} \; //if shelluser for checkout != apacheuser => 775
$> chmod o+w var var/.htaccess app/etc //if shelluser for checkout != apacheuser => og+w
$> chmod 550 mage
$> chmod -R o+w media //if shelluser for checkout != apacheuser => og+w
$> rm -rf var/cache/*
$> rm -rf var/session/*

perhaps you have to use sudo!!!

As a bash script

Or you can place all commands in a shellscript like the following one. I personally put these kind of tools in a folder tools/shellscripts that is situated on the same level as the Magento DocumentRoot (here mage). That’s why the paths have to start with ../../ .

if [ "$1" == "help" ]
    echo "Help";
    echo "USAGE:";
    echo "========";
    exit 0;
elif [ $1 ]

    find ../../mage/ -type f -exec chmod 0644 {} \;

    chmod 550 ../../mage/mage

    #wenn shelluser für checkout == apacheuser dann 755
    find ../../mage/ -type d -exec chmod 2775 {} \;

    rm -rf ../../mage/var/cache/*
    rm -rf ../../mage/var/session/*

    find ../../../../shared/mage/ -type d  -exec chmod 2775 {} \;
    find ../../../../shared/mage/ -type f  -exec chmod 0644 {} \;
    echo "Magento file permissions were resetted!";
    echo "You have to give me the right params, please sir master sir!!!";
    exit 0;


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.