I'm familiar with magento1 and decided to learn about magento2 so I've been trying to install it but am having some difficulties with permissions of folders and files.

I've looked at lots of videos, tutorials and documentations but I can't seem to get it right.

I'm working on ubuntu 20.04, have already installed lamp stack, elasticsearch, composer...

After that, when I switch to the user I've created specifically for that purpose, I create a directory in /var/www/html named magento2 and use composer to download magento 2.4

At this point, I'm supposed to run this command :

cd /var/www/html/magento2 && find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} + && chmod u+x bin/magento

However I'm getting an error saying I don't have the rights for certain files, namely

  • var/composer_home/cache/.htaccess
  • var/composer_home/.htaccess
  • var/.regenerate.lock
  • var/cache/mage--f/mage---ea6_MAGE_VERSION
  • var/cache/mage-tags/mage---ea6_CONFIG
  • var/cache/mage-tags/mage---ea6_MAGE
  • var/log/debug.log
  • var/log/magento.cron.log
  • var/log/system.log
  • generated/code/Magento/Framework/Event/Config/Reader/Proxy.php
  • generated/code/Magento/Framework/Validator/RegexFactory.php
  • generated/code/Magento/Framework/ObjectManager/Config/Reader/Dom/Proxy.php
  • generated/code/Magento/Framework/App/ResourceConnection/Proxy.php
  • generated/code/Magento/Framework/App/ResourceConnection/Config/Proxy.php
  • generated/code/Magento/Framework/Config/Composer/PackageFactory.php
  • generated/code/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php
  • generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php
  • generated/code/Magento/Indexer/Model/Indexer/CollectionFactory.php
  • generated/code/Symfony/Component/Console/Question/QuestionFactory.php
  • generated/code/Symfony/Component/Console/Helper/TableFactory.php
  • generated/code/Symfony/Component/Console/Input/ArrayInputFactory.php
  • generated/code/Composer/Console/ApplicationFactory.php

I've checked their ownership and they link to root instead of magentouser. Other folders and files seem to have the right ownership so I don't understand what's happening...

Any help?

Thank you

1 Answer 1


Fixed it myself.

I've tried reinstalling multiple times as several tutorials I followed didn't bother with permissions while others did.

In the install I described here, I found it strange that cron logs would appear in this attempt as I hadn't gone past the download this time and had executed bin/magento cron:install only once before but as root during an other try.

Turns out the cronjobs were still listed /var/spool/cron/crontabs/root (found those using sudo crontab -l), so I removed those with sudo crontab -r and redownloaded magento as my magento user, the folders had the right ownership this time so the command worked just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.