2

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 :)

1 Answer 1

5

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
2
  • wow thanks.. it works... actually i have tried sudo usermod -a -G www-data sanders before but it didn't work.. I forgot to do chmod -R g+w to that directory lol. Aug 22, 2017 at 7:19
  • Thanks! Adding some keywords to draw the attention of others who may have experienced similar issues: This resolves a move/delete permission for rclone in the case of sftp and SSH_FX_PERMISSION_DENIED
    – eldad-a
    Oct 26, 2020 at 23:41

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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.