The most common scenario is to recursively change the website file’s permissions to 644 and directory permissions to 755.
Using the numeric method:
find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;
Using the symbolic method:
find /var/www/html -type d -exec chmod u=rwx,go=rx {} \;
find /var/www/html -type f -exec chmod u=rw,go=r {} \;
The find command searches for files or directories under /var/www/html and passes each found file or directory to the chmod command to set the permissions.
When using find with the -exec option, the chmod command is run for each found entry. Use the xargs command to speed up the operation by passing multiple entries at once:
find /var/www/html -type d -print0 | xargs -0 chmod 755
find /var/www/html -type f -print0 | xargs -0 chmod 644
Comments