HowTo: Multi User Shared Local Directory

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
altair4
Level 17
Level 17
Posts: 7828
Joined: Tue Feb 03, 2009 10:27 am

HowTo: Multi User Shared Local Directory

Postby altair4 » Mon Apr 04, 2011 8:30 am

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
NOTE: There is a bug in the display manager that Mint uses on all of its current versions that disables any attempt to change the default umask through normal methods. Items [3] [4] [5] and [6] depend on having a umask of 0002 which is the standard default on Ubuntu and most other distros these days instead of the 0022 that mdm imposes. If you want to implement these items there is a way to override the mdm interferance which will have to done to follow this HowTo:

Create a script:

Code: Select all

gksu gedit /etc/profile.d/umask.sh

Add this line - make sure there are no leading spaces before the umask operator:

Code: Select all

umask 0002

Reboot the box.


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.


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
Last edited by altair4 on Thu Mar 26, 2015 2:08 pm, edited 8 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

altair4
Level 17
Level 17
Posts: 7828
Joined: Tue Feb 03, 2009 10:27 am

Re: HowTo: Multi User Shared Local Directory

Postby altair4 » Thu Aug 25, 2011 4:05 pm

METHOD B: Using Bindfs

Please note: This will work in Mint prior to Mint12 and based on where Ubuntu is at the moment it will work in Mint13 and beyound but it will not install in Mint12 because of an infantile mistake in the bindfs package that Ubuntu simply refuses to correct: https://bugs.launchpad.net/ubuntu/+sour ... bug/851600

Initial steps:

[1] Install bindfs

Code: Select all

sudo apt-get 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 /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,group=plugdev /home/Shared /home/Shared

For Mint16 it's:

Code: Select all

sudo bindfs -o perms=0660:+X,force-group=plugdev /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,group=mygroup /home/Shared /home/Shared

For Mint16 it's:

Code: Select all

sudo bindfs -o perms=0660:+X,force-group=mygroup /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:

[1] The simplest way is to add the line without sudo to /etc/rc.local above the "exit 0" line,

[2] Using an Upstart job: - Since Upstart will be gone with Mint18 you should avoid using this method if you pan to upgrade.

* Create an upstart job file:

Code: Select all

gksu gedit /etc/init/bindfs-mounts.conf

* With this content:

Code: Select all

# Create a common directory using bindfs
description "Multi User Shared Directory"

start on stopped mountall

script
  bindfs -o perms=0666:+X /home/Shared /home/Shared
end script

Change the actual script to whatever options you want to use.

* Save the file, exit gedit, and start the upstart job:

Unmount the partition if you mounted it manually:

Code: Select all

sudo umount /home/Shared

Then start the Upstart job:

Code: Select all

sudo initctl start bindfs-mounts

Check the /home/Shared folder and verify that it's working as you desired.

[3] Using fstab

Warining: There is a problem using this method with Ubuntu based Mint. I tried this method first and it failed - and by failed I mean I could not boot into the machine so I had to remove that line in fstab using a rescue disk. The problem is with Ubuntu and there is a bug report concerning the cause of this issue: https://bugs.launchpad.net/ubuntu/+sour ... bug/503003 .

I can follow the procedure below and after the "sudo mount -a" everything works as advertised but after a reboot it fails because of the bug in mountall. If it's like bind itself the problem does not occur in Debian but I have not tried it in LMDE to verify. So the following is informational only:

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

Code: Select all

/home/Shared    /home/Shared    fuse.bindfs    perms=0666:+X    0    0

And instead of this:
sudo bindfs -o perms=0660:+X,group=plugdev /home/Shared /home/Shared
It turns to this:

Code: Select all

/home/Shared    /home/Shared    fuse.bindfs    perms=0660:+X,group=plugdev    0    0

For Mint16 it's:

Code: Select all

/home/Shared    /home/Shared    fuse.bindfs    perms=0660:+X,force-group=plugdev    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
Last edited by altair4 on Sat Jul 16, 2016 6:15 pm, edited 3 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
panorain
Level 4
Level 4
Posts: 263
Joined: Mon Dec 16, 2013 3:21 pm

Re: HowTo: Multi User Shared Local Directory

Postby panorain » Mon Mar 24, 2014 10:48 pm

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,
Linux Mint 17 Qiana
Linux Mint 13 Maya
Ubuntu 10.04
Always =updatedb=
GNU LINUX

altair4
Level 17
Level 17
Posts: 7828
Joined: Tue Feb 03, 2009 10:27 am

Re: HowTo: Multi User Shared Local Directory

Postby altair4 » Tue Mar 25, 2014 6:42 am

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
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
panorain
Level 4
Level 4
Posts: 263
Joined: Mon Dec 16, 2013 3:21 pm

Re: HowTo: Multi User Shared Local Directory

Postby panorain » Tue Mar 25, 2014 11:47 pm

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,
Linux Mint 17 Qiana
Linux Mint 13 Maya
Ubuntu 10.04
Always =updatedb=
GNU LINUX

grungy_me
Level 2
Level 2
Posts: 99
Joined: Mon Sep 30, 2013 3:54 pm

Re: HowTo: Multi User Shared Local Directory

Postby grungy_me » Tue Aug 19, 2014 5:03 pm

@altair4

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

altair4
Level 17
Level 17
Posts: 7828
Joined: Tue Feb 03, 2009 10:27 am

Re: HowTo: Multi User Shared Local Directory

Postby altair4 » Tue Aug 19, 2014 5:30 pm

It should.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

grungy_me
Level 2
Level 2
Posts: 99
Joined: Mon Sep 30, 2013 3:54 pm

Re: HowTo: Multi User Shared Local Directory

Postby grungy_me » Wed Aug 20, 2014 9:56 am

@altair4

Cool! Thank you. :)

grungy_me
Level 2
Level 2
Posts: 99
Joined: Mon Sep 30, 2013 3:54 pm

Re: HowTo: Multi User Shared Local Directory

Postby grungy_me » Mon Sep 15, 2014 2:36 pm

Just for anyone else that needs to know, I just confirmed that the bindfs solution works on LinuxMint 17 64-bit XFCE.

User avatar
panorain
Level 4
Level 4
Posts: 263
Joined: Mon Dec 16, 2013 3:21 pm

Re: HowTo: Multi User Shared Local Directory

Postby panorain » Mon Oct 06, 2014 11:16 pm

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.
Last edited by panorain on Sun Nov 02, 2014 4:37 pm, edited 1 time in total.
Linux Mint 17 Qiana
Linux Mint 13 Maya
Ubuntu 10.04
Always =updatedb=
GNU LINUX

grungy_me
Level 2
Level 2
Posts: 99
Joined: Mon Sep 30, 2013 3:54 pm

Re: HowTo: Multi User Shared Local Directory

Postby grungy_me » Tue Oct 07, 2014 9:29 am

@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.


Return to “Tutorials”

Who is online

Users browsing this forum: Google Feedfetcher and 4 guests