1

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.

3

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
2

Use these commands to overwrite 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    
1

Give full control (read/write/execute) to var directory.

sudo chmod -R 777 var

You can also try running command using sudo

sudo php bin/magento {your command}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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