drupal 8 entity permissions code example
Example: drupal file permissions
cd /var/www/html/drupal9
sudo chown -R my-user:apache .
sudo find . -type d -exec chmod 750 '{}' \;
sudo find . -type f -exec chmod 640 '{}' \;
cd web/sites
sudo find . -type d -name files -exec chmod 770 '{}' \;
for d in ./*/files
do
sudo find $d -type d -exec chmod 770 '{}' \;
sudo find $d -type f -exec chmod 660 '{}' \;
done