Sharing directories among several users

In Linux you can share directories among several users. For instance, several people are working on a project and they need to create documents and programs so that others in the group can edit and execute these documents as needed. The project resides in the ‘/home/share‘ directory.

This is how you achieve it.

#  /usr/sbin/groupadd share
#  chown -R root.share /home/share
#  /usr/bin/gpasswd -a <username> share
#  chmod 2775 /home/share

Now do a long listing of the /home/share directory and you will see that it has a sticky bit for the group denoted by ‘s’.

 $  ls -ld /home/share
             drwxrwsr-x    2 root     share        4096 May  22 16:19 /home/share
                   ^---------- Note the s bit, which was set with the chmod 2775

 $  cat /etc/group
    ...
    share:x:502:grok,moe,larry
          ...          ^------- users are added to this group.

The user may need to login again to get access. Or, if the user is currently
logged in, they can run the following command:

$ su - <username>

Note, the above step is recommended over “newgrp - share” since currently
newgrp in FC2,FC3, and FC4 gets access to the group but the umask is not
correctly formed.

As root you can test their account.

$ su - <username>

Note: You need to ‘-’ to pickup their environment ‘$ su - moe‘ .

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Related posts: