How To Set Readonly File Permissions On Linux / Unix Web Server DocumentRoot

To set read-only permissions on a directory in Linux or Unix, you can use the chmod command. The chmod command is used to change the permissions of a file or directory.

For example, to set read-only permissions on the /var/www/html directory (which is often used as the document root for web servers), you would use the following command:

chmod 755 /var/www/html

This sets the permissions on the /var/www/html directory to 755, which means that the owner has read, write, and execute permissions, while others have only read and execute permissions. This is a common permissions setting for web server document roots, as it allows the web server to read and execute the files it needs to serve content, while preventing others from modifying those files.

You can also set the permissions to 644, which means that the owner has read and write permissions, while others have only read permissions:

chmod 644 /var/www/html

This is a more restrictive setting, as it only allows the owner to modify the files, but it can be useful in certain situations where you want to prevent others from making changes to the content of your web server.

Leave a Comment