Jul/090
Linux: Share a directory between local users
I spent a few hours yesterday trying to get this done but ran into several problems, and worst of all, I couldn’t find one single post addressing all permission problems associated with allowing several users access to the same directory for read/write operations.
The best way of creating a shared directory is to create a user and group, and then a home directory. Make other users members of the new group and set permission inheritence to propagate to child objects regardless of the user who is creating or uploading the file.
User name is shareowner and group, sharedhome.
Create a user, group and home directory for the new user:
useradd -d /home/shareowner -g sharedhome -m shareowner
The above command creates a user and group as user’s primary group. I wouldn’t create a password for the user if I don’t want the user to actually be able to logon to the server. Once the home directory is created I will add the existing users to the new group:
usermod -G sharedhome existinguser1 usermod -G sharedhome existinguser2
and so on. Note that I use -G and not -g, as I want users to become additional users of the new group. Now we set permissions for the new directory… I make shareowner the owner, and sharedhome the group that owns the directory:
chown -R shareowner:sharedhome /home/sharedhome
Then I use umask and chmod to force all files in /home/sharedhome to inherit permissions from the top directory:
umask 002 chmod -R g+s /home/sharedhome
That’s it. Now existinguser1 and existinguser2 should have read/write permission to /home/sharedhome directory.
Recent Comments
- Nathan Friend on Linux: Cannot move folders – inter-device move failed, unable to remove target: Is a directory
- Ali on Windows: Windows is unable to install to the selected location. Error: 0×80300001
- David McLaughlin on Windows: Windows is unable to install to the selected location. Error: 0×80300001
- Jon on Windows: Windows is unable to install to the selected location. Error: 0×80300001
- Espen Telvik on Windows: Windows is unable to install to the selected location. Error: 0×80300001
Tag Cloud
Categories
Google Sci/Tech Feed
- Top Tax Tips From Zuckerberg's Facebook Bonanza - Forbes
- Astronomers: Mars likely too dry for life - The State Column
- Women and Leadership: Sheryl Sandberg and the Facebook IPO - Technorati
- German Apple Sales Resume as Court Suspends Injunction - ITProPortal
- Tiles and extra security: Windows 8 is coming - The Hindu