nixCraft Poll

Topics

FreeBSD : How to setup shared directories

Posted by Vivek Gite [Last updated: June 18, 2005]

Recently one of the new admin come across classic problem of "Sharing Directories Among Several User". I explained him the commands and decided to write this. Although concept is almost same as Linux/UNIX; still people comes across problem. Here is scenario:

(A) Create a shared directory /home/project1

# mkdir /home/project1

(B) Create the group project1

# pw group add project1

(C) Add user padmin and setup password:

# pw user add -n padmin -d /home/project1 -g project1 -m
# passwd padmin

(D) Add rest of users to group project1

# pw user add -n usr1 -d /home/project1 -g project1
# pw user add -n usr2 -d /home/project1 -g project1

....

# passwd usr1
# passwd usr2

...

(E) Setup permission on /home/project1 directory as follows:

a) Setup group ownership to project1 group:

# chown -R padmin.project1 /home/project1

b) Setup permission on directory i.e. setup full permission for group and owner on a directory:

# chmod -R 775 /home/project1

c) Setup sgid bit. So what is sgid bit? Normally when ever 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 project1 group can create/alter files in /home/project1 directory:

# chmod -R 2775 /home/project1

OR

# chmod -R g+s /home/project1

Now each user can login over ssh and use the directory for project. Note if you wish to add an existing users to project1 group for sharing files then use pw command as follows:

# pw user mod -n username -G project1

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.