recursive command to set permission

leonep

Well-Known Member
Nov 18, 2014
234
19
68
Pescara
cPanel Access Level
Root Administrator
Hi,
i want to know if is secure to use the recursive commands for assign the permissions. i have read something here time ago with security problem about recursive chown

this command can be consider safe ? i use suPhP
the purpose is to correct all files in public_html

for user in `ls -1 /var/cpanel/users | grep -v "\/"`; do find /home/$user/public_html/ -name "*" | sed 's/ /\\ /g' | xargs -n 1 chmod 644; find /home/$user/public_html/ -type d | sed 's/ /\\ /g' | xargs -n 1 chmod 755; find /home/$user/subdomains/ -name "*";find /home/$user/subdomains/ -type d | sed 's/ /\\ /g' | xargs -n 1 chmod 755;done


thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Hello,

It's generally advised to avoid using recursive chown or chmod commands. For instance, it's possible a user has intentionally configured the permissions on a file/directory to something other than 0755 or 0644.

Thank you.