Page 1 of 1

HowTo: Multi User Shared Local Directory

Posted: Mon Apr 04, 2011 8:30 am
by altair4
HowTo: Multi User Shared Local Directory

I will offer two methods in this HowTo.

Method A: Using traditional linux ownership and permissions ( the first post in this topic )
Method B: Using Bindfs ( the second post in this topic )

Method A: Using Linux Permissions

Creating a "shared" local directory between multiple local users depends on your definition of "shared". The following are examples of options on how you would set up a shared directory accessible by local users.

I'm going to start by creating the directory to be shared:

Code: Select all

sudo mkdir /home/Shared
This will create a directory with root as owner and with permissions of 755 meaning root can read and write and everyone else can only read.

[1] All users can add to and delete from the folder and can read but not write to each others files:

Code: Select all

sudo chmod 0777 /home/Shared
[2] All users can add to but can only delete files they own and can read but not write to each others files:

Code: Select all

sudo chmod 1777 /home/Shared
Note: The "1" is a "sticky bit": A file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the directory, or root.

[3] All users can add to and delete from the folder and can read and write to every file:

Code: Select all

sudo chown :plugdev /home/Shared
sudo chmod 2775 /home/Shared
Note1: You may have to add your users to the plugdev group depending on how you added the user:

Code: Select all

sudo gpasswd -a mary plugdev
Logout and log back in again for the group change to take affect.[/color]

Note2: The "2" in "chmod 2775" is the setgid bit. All files saved to a directory with that bit set will inherit the group of the directory.
Note3: Changing the global umask from 022 to 002 will force every saved folder / file to save with permissions of 775 / 664. So all users who are members of the group will have read / write access to all new folders / files.

[4] All users can add to but can only delete files they own and can read and write to every file:
Same as [3] above except "sudo chmod 2775 /home/Shared" is changed to this:

Code: Select all

sudo chmod 3775 /home/Shared
Note: the "3" is a combination of the "1" sticky bit + the "2" getgid bit.

[5] Only some users can add and delete from the folder and can read and write to every file:

Code: Select all

sudo groupadd special
sudo gpasswd -a mary special
sudo chown :special /home/Shared
sudo chmod 2770 /home/Shared
Note: You are creating a unique group, adding specific users to that group, making the folder accessible only to that group, and making sure every new file added to that directory is write accessible to that group.

[6] Only some users can add to but can only delete files they own and can read and write to every file
Same as [5] except "sudo chmod 2770 /home/Shared" is changed to this:

Code: Select all

sudo chmod 3770 /home/Shared

Re: HowTo: Multi User Shared Local Directory

Posted: Thu Aug 25, 2011 4:05 pm
by altair4
METHOD B: Using Bindfs

Initial steps:

[1] Install bindfs

Code: Select all

sudo apt install bindfs
[2] Create a shared directory:

Code: Select all

sudo mkdir /home/Shared
Manual Mounts:

[1] Access to all

Code: Select all

sudo bindfs -o perms=0666:+X,x-gvfs-hide,nonempty /home/Shared /home/Shared
All folders and subfolders will have permissions of 777 allowing anyone to access them.
All files will be 666 except those files that are executable to begin with in which case they will be 777.
This will give everyone read / write access to individual files and the ability to execute any files marked as such.

All existing files / folders and any new or copied files / folders will assume these permissions.

[2] You could restrict access to only local login users by modifying the mount command to this:

Code: Select all

sudo bindfs -o perms=0660:+X,force-group=plugdev,x-gvfs-hide,nonempty /home/Shared /home/Shared
[3] You can even restrict it further to a subset of the local login users by creating your own group:

Code: Select all

sudo bindfs -o perms=0660:+X,force-group=mygroup,x-gvfs-hide,nonempty /home/Shared /home/Shared
Then you would have to create the new group:

Code: Select all

sudo groupadd mygroup
And add all your users to that group:

Code: Select all

sudo gpasswd -a mary mygroup
Note: To undo the mounts run the following command:

Code: Select all

sudo umount /home/Shared
Auto Mount at Boot Using fstab:

The syntax for fstab changes somewhat I'm afraid. So instead of this in a terminal:
sudo bindfs -o perms=0666:+X,x-gvfs-hide,nonempty /home/Shared /home/Shared
It turns to this in fstab:

Code: Select all

/home/Shared    /home/Shared    fuse.bindfs    perms=0666:+X,x-gvfs-hide,nonempty    0    0
And instead of this:
sudo bindfs -o perms=0660:+X,force-group=plugdev,x-gvfs-hide,nonempty /home/Shared /home/Shared
It turns to this:

Code: Select all

/home/Shared    /home/Shared    fuse.bindfs    perms=0660:+X,force-group=plugdev,x-gvfs-hide,nonempty    0    0
After you add the lines in fstab run the following command which will test for errors and mount the directory:

Code: Select all

sudo mount -a
Further information on bindfs can be found here: http://www.cs.helsinki.fi/u/partel/bind ... dfs.1.html

Re: HowTo: Multi User Shared Local Directory

Posted: Mon Mar 24, 2014 10:48 pm
by panorain
Thank you, for the wonderful tutorial and your time.

Is there a way to simply add a file folder named 'Shared' to the desktop on Cinnamon/Mate/etc that actually sticks and can be used simply; other than digging into filesystem within Nemo every time one would like to add a file to the '/home/Shared' folder?

Thank you,

Re: HowTo: Multi User Shared Local Directory

Posted: Tue Mar 25, 2014 6:42 am
by altair4
My normal desktop is XFCE where this is easy to do but I never noticed before that Nemo has no "Send To" option in it.

Anyway, right click the desktop > Create a New launcher here:

Name: LocalShare
Command: nemo /home/Shared

Re: HowTo: Multi User Shared Local Directory

Posted: Tue Mar 25, 2014 11:47 pm
by panorain
Certainly appreciate your response and the research you do.

I cannot tell you how much a noob-beginner like me appreciates your help.

Thank you,

Re: HowTo: Multi User Shared Local Directory

Posted: Tue Aug 19, 2014 5:03 pm
by grungy_me
@altair4

Does the bindfs instructions for making a shared folder for LinuxMint 17 64-bit XFCE work safely as is?

Re: HowTo: Multi User Shared Local Directory

Posted: Tue Aug 19, 2014 5:30 pm
by altair4
It should.

Re: HowTo: Multi User Shared Local Directory

Posted: Wed Aug 20, 2014 9:56 am
by grungy_me
@altair4

Cool! Thank you. :)

Re: HowTo: Multi User Shared Local Directory

Posted: Mon Sep 15, 2014 2:36 pm
by grungy_me
Just for anyone else that needs to know, I just confirmed that the bindfs solution works on LinuxMint 17 64-bit XFCE.

Re: HowTo: Multi User Shared Local Directory

Posted: Mon Oct 06, 2014 11:16 pm
by panorain
grungy_me > could you start a new post on encrypted volumes using bindfs with lm 17'? I am here. I would like your opinion with your research.'

Struggling along->

Thank you.

Re: HowTo: Multi User Shared Local Directory

Posted: Tue Oct 07, 2014 9:29 am
by grungy_me
@panorain

I'm sorry but I know nothing about that. I was just following user altair4's instructions here to make a shared directory. Why don't you create a new post and ask whatever you are having problems with? Someone with experience with that is bound to answer.