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.
Related posts:
- Linux: User management
- Linux: Crontab notes for different users – run a cron job every time a system reboots
- Windows: Cannot add Active Directory Users and Computers snap-in in Windows XP 64 bit
- Linux: A simple and quick way of sharing a folder with Windows systems using Samba
- Linux: vsftpd and symbolic links
Enjoy this article?
No comments yet.
Leave a comment
No trackbacks yet.
Recent Comments
- Reset iptables Rules – shkschneider's Blog on Linux: Reset iptables firewall rules
- Robert Chase on Windows: Windows is unable to install to the selected location. Error: 0×80300001
- Necdet Yücel on Debian: Squeeze cannot load Broadcom LAN drivers bnx2/bnx2-mips-09-5.0.0.j3.fw
- Ali on Debian: Lenny cannot load Broadcom NIC drivers, asking for firmware bnx2-06-4.0.5.fw or bnx2-09-4.0.5.fw during install
- Simon on Debian: Lenny cannot load Broadcom NIC drivers, asking for firmware bnx2-06-4.0.5.fw or bnx2-09-4.0.5.fw during install
