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:
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 6 comments… read them below or add one }
My problem is that when usr1 creates a file foo in /home/myproj he then becomes the owner of foo and no one else can edit it. How can I cause files and dirs under /home/myproj to be accessed (read write del) by all the users in the group?
ls -l /home/myproj
-rw-r–r– 1 usr1 users 5 May 31 03:37 foo
Hey, should be : instead of . in 5.a.
Thanks for the tutorial!
I made a web group, added the users.
Made a directory called test
chown root.web test -R
chmod 2775 test -R
I can see the guid bit set, but when I make a file in the test directory, it does not have group write permissions? the file is root.web but the permissions are 644.
I thought since the directory was 2775, the files that are created inside are 664… Did I do something wrong?
Group members need to add files and then other group members need to write to them.
The reason this doesn’t work as Jon and Dunlap want:
Setgid when set on a directory (e.g., the 2 in 2775) basically only specifies the default group for new files not their permissions. The permissions will still be dictated by umask; so you should set umask 002 (so new files are created with read/write permission for everyone in the group by default — the normal umask is 022).
This is normally done in /etc/profile or in each users ~/.profile or ~/.bashrc
I actually found that my issue had to do with php ssh2. I was using Wordpress auto upgrade feature and the files would get created but without the correct file permission. I was able to use filezilla sftp for the developers to upload and create files which worked.
I made a change to the mask in the wordpress config that created group writable files.
i have a drive in windows server 2003 and I want share this drive for one user
this user use a linux Red Hat OS and i want just this user modify this drive and other network user can’t any modify this folder
How can i ddo this
by Active directory User How?