I am a new system admin and learning Ubuntu. I have to setup a restricted (permission) for directories in Apache web server. The scenario is as follows. The folders are,


The users in hrd (HR Department) group must access /var/www/hrd/ contents only.

The users in technical group must access /var/www/technical/ contents only.

The users in management group can access all the contents.

All the users & groups can access the common /var/www/data/ directory.

How to implement this? Can anyone help me out? Thanks in advance.


1. Installation

The Apache2 web server is available in Ubuntu Linux. To install Apache2:
At a terminal prompt enter the following command:

sudo apt-get install apache2

2. Configuration and with care about 3. HTTPS Configuration

4. Sharing Write Permission

For more than one user to be able to write to the same directory it will be necessary to grant write permission to a group they share in common. The following example grants shared write permission to /var/www/html to the group "webmasters".

sudo chgrp -R webmasters /var/www/html
sudo find /var/www/html -type d -exec chmod g=rwxs "{}" \;
sudo find /var/www/html -type f -exec chmod g=rw  "{}" \;

These commands recursively set the group permission on all files and directories in /var/www/html to read write and set user id. This has the effect of having the files and directories inherit their group and permission from their parent. Many admins find this useful for allowing multiple users to edit files in a directory tree.

If access must be granted to more than one group per directory, enable Access Control Lists (ACLs).

| improve this answer | |
  • Hello swift, since I am the newbie, I referred the below URL – Govind Raj Apr 26 '16 at 6:28
  • Hello swift, I referred the URL blog.secaserver.com/tag/htpasswd-group for Group Authentication. When I checked in Firefox I get this message : Forbidden You don't have permission to access /secure-admin/ on this server. Then I checked the error file : /var/log/apache2/error.log it shows : Permission denied: access to /secure-admin/index.php denied (filesystem path '/home/website/public_html/secure-admin/index.php') because search permissions are missing on a component of the path. Then I changed the permission by command chmod -R 774. Now it gives access to all, not denying. – Govind Raj Apr 26 '16 at 6:43
  • if you mean web users (i.e. internet users) then sure your link have methods to configure your .htpasswd file with needed permissions. otherwise if you need control or limiting your OS's users or webmasters then you should to use my solution. – swift May 10 '16 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.