linux - Bash check if all files in a folder are writable by www-data -


i have logs folder , log files owned root, need them owned www-data.

i'm writing script check if owned www-data = writable user.

#!/bin/bash rootfiles=$(ls -la /tmp/logs/ | grep root | sed -e 's/\s*$//') if [[ ! -z "$rootfiles" ]];     exit 1 fi exit 0 

this works fine, if assume there'll no file contains word root in it's name, , that's not root www-data.

how make more robust?

you can use find find out:

find /tmp/logs -not -user www-data 

but, to change owner of files, can use recursive chown:

chown -r /tmp/logs/* www-data 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -