Salman El Farisi
Salman El Farisi

Reputation: 106

Remove www-data owned file using ordinary user

i have a folder which contain uploaded file. for example /var/www/app/storage/public :

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 root user. What should i do if i want to delete those files using ordinary user like sanders so i can do something like:

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

Thank you :)

Upvotes: 3

Views: 5419

Answers (1)

Patrick Adler
Patrick Adler

Reputation: 196

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

Upvotes: 5

Related Questions