Access a folder from another user

7,738

You gave access to user2 to the specific sub-folder: /home/tools/domains/domain.tools.com/public_html/storage/users

I assume that the reason you failed to access that folder by user2 is that user2 can't access some folders in the upper level of the folder hierarchy.

One possible way to solve it, might be added the x (change directory) permission to all directories above that folder to all users.

As user tools (or as root by using sudo) you can give the x permission on all directory (e.g.):

chmod +x /home/tools
chmod +x /home/tools/domains
chmod +x /home/tools/domains/domain.tools.com
chmod +x /home/tools/domains/domain.tools.com/public_html
chmod +x /home/tools/domains/domain.tools.com/public_html/storage
chmod +x /home/tools/domains/domain.tools.com/public_html/storage/users
Share:
7,738
Peter Mortensen
Author by

Peter Mortensen

(Last updated 2018-04-15.) Experienced application developer. Software Engineer. M.Sc.E.E. C++ (10 years), software engineering, .NET/C#/VB.NET (7 years), usability testing, Perl, scientific computing, Python, Windows/Macintosh/Linux, Z80 assembly. Some useful links related to Super User: Find Ubuntu version (and Linux kernel version) My other accounts: Experienced application developer. Software Engineer. M.Sc.E.E. C++ (10 years), software engineering, .NET/C#/VB.NET (7 years), usability testing, Perl, scientific computing, Python, Windows/Macintosh/Linux, Z80 assembly. My other accounts: iRosetta. [/]. Stack Overflow (SO). [/]. Server Fault (SF). [/]. Super User (SU). [/]. Meta Stack Overflow (MSO). [/]. Careers. [/]. Other My 15 minutes of fame on Super User Blog. Sample: Jump the shark. LinkedIn profile @PeterMortensen (Twitter) Google profile Quora profile GitHub profile Full jump page with other SOFU related, Stack Exchange sites, etc. Contact I can be contacted through this reCAPTCHA (requires JavaScript to be allowed from google.com).

Updated on September 18, 2022

Comments

  • Peter Mortensen
    Peter Mortensen over 1 year

    I'm working with PHP, and I'm trying to access a folder of another user, and I always get the error "Permission denied".

    I have created a group, added both users and grant access. It doesn't help, and here is what I did (from root access):

    sudo usermod -a -G mygroup tools
    sudo usermod -a -G mygroup user2
    
    sudo chgrp -R mygroup /home/tools/domains/domain.tools.com/public_html/storage/users
    
    sudo chmod -R 2775 /home/tools/domains/domain.tools.com/public_html/storage/users
    
    chmod ug+rwx -R /home/tools/domains/domain.tools.com/public_html/storage/users
    

    Now, when I'm trying to access the folder from the user "tools" (where this folder is located), I can do it easily with no problem:

    [tools@server ~]$ ls -l /home/tools/domains/domain.tools.com/public_html/storage/users
    total 4
    drwxrwsr-x 7 root mygroup 4096 Dec 18 17:36 id
    

    But, if I try to access this folder from a different user (in the same group), I get this error:

    [user2@server ~]$ ls -l /home/tools/domains/domain.tools.com/public_html/storage/users
    ls: cannot access /home/tools/domains/domain.tools.com/public_html/storage/users: Permission denied
    

    How can I fix this problem?