Ask a Question
Advertise on boostr.in
how Are the Permissions and Ownership Set Correctly on linux os?
In order for the web server to correctly serve files, it must be able to read the files and have access to the directories where they are kept. This can be controlled through the file and directory permissions and ownership.
To read files, the directories containing the content must be readable and executable by the web server process. User and group name that are used to run the web server differ from distribution to distribution.
On Ubuntu and Debian, both Apache and Nginx run as the user www-data which is a member of the www-data group.
On CentOS and Fedora, Apache runs under a user called apache which belongs to the apache group. Nginx runs under a user called nginx which is a part of the nginx group.
Using this information, You can look at the directories and files that make up your site content:
ls -l /path/to/web/root
The directories should be readable and executable by the web user or group, and the files should be readable in order to read content. In order to upload, write or modify content, the directories must additionally be writeable and the files need to be writeable as well. Set directories to be writable with great caution though, because it can be a security risk.
To modify the ownership of a file, you can do this:
sudo chown user_owner:group_owner /path/to/file
This can also be done to a directory. You can change the ownership of a directory and all of the files under it by passing the -R flag:
sudo chown -R user_owner:group_owner /path/to/file
Jun 9, 2015
Sep 9, 2015
to add a comment.
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please