Magento – Command line user does not have read and write permissions on var/generation directory

magento2

Command line user does not have read and write permissions on
generated directory. Please address this issue before using Magento
command line.

I getting above error while run below comands:-

php bin/magento indexer:reindex
php bin/magento cache:flush

php bin/magento cache:clean

Please help me how can I resolve this issue. Please help me.

Best Answer

If you would just read Magento's documentation

Set file permissions

You must set read-write permissions for the web server group before you install the Magento software. This is necessary so that the Setup Wizard and command line can write files to the Magento file system.

cd /var/www/html/<magento install directory>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data . // Ubuntu
chmod u+x bin/magento
Related Topic