Salman El Farisi Salman El Farisi - 1 month ago 14
Apache Configuration Question

Remove www-data owned file using ordinary user

i have a folder which contain uploaded file. for example


ls -al /var/www/app/storage/public
-rw-r--r-- 1 www-data www-data 835870 Aug 22 13:42 8b4c4e2a3d64.pdf
-rw-r--r-- 1 www-data www-data 835870 Aug 22 13:24 3d326ab2b3bc.pdf

I want to make a script to clean up that directory without using
user. What should i do if i want to delete those files using ordinary user like
so i can do something like:

sanders@localhost:~$ rm -rf /var/www/app/storage/public

Thank you :)

Answer Source

You will have to add this user to your "www-data" group:

sudo usermod -a -G www-data sanders

Then, make sure your folders have the correct group permissions:

sudo chgrp -R www-data /var/www/app/storage/public
sudo chmod -R g+w /var/www/app/storage/public