Linux setup shared directory
Sharing a directory among users in same group is one of the essential tasks. You need to use chmod command and add user to appropriate group. To make idea clear here is an scenario:
- /home/myproj : is shared directory
- usr1, usr2, ... usrN : would like to work and share files in /home/myproj directory
- padmin : Main project administrator user
Step # 1: Create a shared directory /home/myproj
If this directory does not exist then create it:
# mkdir /home/myproj
Step # 2: Create the group shared group
You need to create a new group. Let us assume group name is myproj
# groupadd myproj
Step # 3: Add user project administrator (padmin) and setup password:
# useradd -d /home/myproj/ -g myproj -m padmin # passwd padmin
Step #4: Add rest of users to group myproj
# useradd -d /home/myproj/ -g myproj usr1 # passwd usr1
Add second user:
# useradd -d /home/myproj/ -g myproj usr2 # passwd usr2
... and so on...
Step #5: Setup permission on /home/myproj directory as follows:
(a) Setup group ownership to myproj group:
# chown -R padmin.myproj /home/myproj/
(b) Setup full permission for group and owner on a directory:
# chmod -R 775 /home/myproj/
(c) Setup sgid bit. So what is sgid bit? Normally whenever you creates file in a directory it belong to default group of user. When a file is created in a directory with the sgid bit set it belogns to the same group as the directory. The result is all users of myproj group can create/alter files in /home/myproj directory:
# chmod -R 2775 /home/myproj/
OR
# chmod -R g+s /home/myproj/
See also:
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Unix Create a Symbolic Link
- Ubuntu Linux NFS Server installation and Configuration
- How Linux file permissions work
- Unable to create installation source - Add directories into YaST as an installation source
- Freebsd: /libexec/ld-elf.so.1: Shared object "libc.so.6" not found Error and Solution
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


Recent Comments
Today ~ 7 Comments
Today ~ 33 Comments
Today ~ 2 Comments
Today ~ 1 Comment
Today ~ 2 Comments