Magento 2 recommadedrecommended folder and file permission
Please follow folowingfollowing terminal commands for folder and file permission.
find . -type f -exec chmod 644 {} ;
find . -type d -exec chmod 755 {} ;
find var pub/static pub/media generated/ app/etc -type f -exec chmod g+w {} ;
find var pub/static pub/media generated/ app/etc -type d -exec chmod g+ws {} ; chown -R : .
chmod u+x bin/magento
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find var pub/static pub/media generated/ app/etc -type f -exec chmod g+w {} \;
find var pub/static pub/media generated/ app/etc -type d -exec chmod g+ws {} \;
chown -R :<web server group> .
chmod u+x bin/magento
It worked like charm