How to change permissions for folders and subfolders

Setting the appropriate file permissions for any web application is a vital part of web hosting. In this tutorial, you will learn how to frequently change file permissions on folders and subfolders in one command.

As we know, in Linux everything is treated as a. Folders are also known as directory files referenced by ‘dIn the Permissions section. The command below will assign the owner to www-data And the group’s owner ubuntu For all files, directories and subdirectories. Use the chown command to change folder and subfolder permissions.

sudo chown -R www-data:ubuntu /var/www/html

Use the chmod command to change permissions for all files, directories, and subdirectories.

sudo chmod -R 755 /var/www/html

Note – Permissions 755 are suitable for assigning them to directories, but not to files. Permission 755 means setting the executable bit on files that are not recommended for a production environment that are excluded from certain cases. We recommend setting separate permissions for files and directories.

Set permissions on files:

sudo find /var/www/html -type f -exec chmod 644 {} ;

While using the permissions on the directory:

sudo find /var/www/html -type d -exec chmod 755 {} ;

Completed.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *