From this user on fresh installation impossible run any command in terminal.

[user@s1 public_html]$ bin/magento c:f
Class Magento\Framework\App\ResourceConnection\Proxy does not exist
[user@s1 public_html]$

When I try delete example generated folder Permission denied:

[user@s1 public_html]$ [fsgroup@s1 public_html]$ rm -rf generated
[user@s1 public_html]$ rm: cannot remove 'generated/.htaccess': Permission denied

When I try add privileges to files/folders:

chown -R www-data:www-data /var/www/magento2/ 
chmod 777 -R var
chmod 777 -R generated
chmod 777 -R app/etc

also return this user not have privileges to use this command. How to solve issue and how to give privileges to user?

  • it owner ship issue.
    – Amit Bera
    Mar 14, 2021 at 6:03

1 Answer 1


First thing first - files&folders ownership - You either swap to root user in order to execute the change the ownership command, or you add the current user in the sudoers group.

Next, running magento commands - you should always run magento cli commands using the webserver user (www-data) and not root or other user, otherwise you end up in the same situation you are now in.

Your Answer

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

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