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
Edit /etc/profile as root: Note: This step from Mint12 forward is no longer necessary as the umask has already been set to 002 for this purpose.
- Code: Select all
gksu gedit /etc/profile
Find the line at the bottom that references umask and change it to:
- Code: Select all
umask 002
Logout and log back in again since profile is read only once at login.
Note1: The above works in Ubuntu-based Mint because all users are members of plugdev by default. If you're using Debian-based Mint you will need to add each user to the plugdev group:
- 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
Edit /etc/profile as root: Note: This step from Mint12 forward is no longer necessary as the umask has already been set to 002 for this purpose.
- Code: Select all
gksu gedit /etc/profile
Find the line at the bottom that references umask and change it to:
- Code: Select all
umask 002
Logout and log back in again since profile is read only once at login.
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

