The information in this thread has been moved to https://help.ubuntu.com/community/Bi...toryLocalUsers
A thread for discussion of the wiki page only can be found here http://ubuntuforums.org/showthread.p...8#post12062098
Thread closed.
Before you start
This guide assumes that you already know:
Introduction
The guide is aimed to show you how to allow multiple local users to read and write (create, delete, rename, modify...) all files (including newly created ones) from a shared directory and its subdirectories. If you want to set up more advanced permissions for different users and/or group try ACLs.
About bindfs
bindfs is a FUSE filesystem for mounting a directory to another location (mountpoint), with permission settings. It allows you to specify the ownership and permissions of the files from inside the mountpoint.
Steps
1. Installing bindfs
2. Create the shared directory
3. Setting the permissions with bindfs
4. Testing the settings (Tips & Tricks)
5. Setting the permissions at boot time
Method 1 - fstab
Method 2 - Upstart
6. That's all :)
1. Installing bindfs
Since Ubuntu 8.10 (Intrepid Ibex), bindfs is in the unverse repository.
- Make sure that the repo is enabled, open up a terminal and run:
Code:
sudo software-properties-gtk --enable-component universe
sudo apt-get update
- Install it:
Code:
sudo apt-get install bindfs
If you are using 8.04 (Hardy Heron), you can install it from this ppa repository or compile it by hand.
2. Createing the shared directory
- e.g. in the /home directory:
Code:
sudo mkdir /home/shared
NOTE: If the directory already exist skip this step.
- allow only root to access it, we will set the permissions later with bindfs:
Code:
sudo chown root: /home/shared
sudo chmod 0700 /home/shared
3. Setting the permissions with bindfs
- Now use the bindfs command to mount the shared directory with altered permissions.
Syntax of the command:
Code:
bindfs [options] dir mountpoint
1. example:
Code:
sudo bindfs -o perms=0700,mirror-only=user1:user2:user3 /home/shared /home/shared
perms=0700 sets the permissions to 0700 (read/write for the owner, none for the group and other);
mirror-only=user1:user2:user3: user1, user2 and user3 will see itself as the owner of the files (user names are separated by a colon).
2. example:
Code:
sudo bindfs -o perms=0750,mirror=user1:user2:user3,group=groupX /home/shared /home/shared
perms=0750 sets the permissions to 0750 (read/write for the owner, read permission for the group and none for other);
group=groupX makes all files owned by the group groupX
For more options, see:
- To unmount the directory:
Code:
sudo umount /home/shared
4. Testing the settings (Tips & Tricks)
Log in as user1 (user2, user3...) and try to create/delete/rename files in the shared direcctory. You can use the CLI for testing:
- To try out different permissions you have to unmount the directory (3.ii.) then remount it with different permissions (3.i.).
- You can use su or sudo to log in as a different user:
Code:
sudo -u username -i
su prompts for the target user's (username's) password, while sudo prompts for your admin password.
To log out the user press Ctrl+d or run:
- You can run the file manager as a different user.
1. Allow the user to connect to the X server:
Code:
xhost +SI:localuser:username
2. Run the file manager:
Code:
sudo -u username -i nautilus /home/shared
3. Test the permissions, then close the file manager.
4. Remove the user form the list of allowed users to connect to the X server:
Code:
xhost -SI:localuser:username
5. Setting the permissions at boot time
Method 1 - fstab
NOTE: Because of a BUG in mountall this method doesn't work, in Ubuntu 9.10 or higher (including Natty 11.04 Alpha-1), if the shared directory is not on the root (/) partition. For a workaround see Method 2 - Upstart below.
- Backup the fstab file:
Code:
sudo cp /etc/fstab{,-backup}
- Open it in a text editor:
Code:
gksu gedit /etc/fstab
- Add an entry at the end of the file. The syntax of an entry:
Code:
bindfs#/path/to/dir /path/to/dir fuse options 0 0
1. example:
Code:
bindfs#/home/shared /home/shared fuse perms=0700,mirror-only=user1:user2:user3 0 0
2. example:
Code:
bindfs#/home/shared /home/shared fuse perms=0750,mirror=user1:user2:user3,group=groupX 0 0
- Save the file and exit.
- Unmount the partition and mount all filesystems mentioned in fstab to check if the entry works as expected:
Code:
sudo umount /home/shared
sudo mount -a
- If something went wrong, restore the original fstab file:
Code:
sudo cp /etc/fstab{-backup,}
Or edit it and remove the line you added.
Method 2 - Upstart
NOTE: This method should work in Ubuntu 9.10 or higher. If you are using an earlier release the fstab method is preferred.
We need to create an Upstart job, which executes the bindfs command after all filesystems are mounted.
- Create the job file and open it for editing:
Code:
gksu gedit /etc/init/mount-bindfs.conf
- Paste the following code into the file:
Code:
# Remount directories with bindfs
#
# Temporary workaround until BUG 503003 is fixed
#
description "Remount directories with different permissions"
start on stopped mountall
script
bindfs -o perms=0700,mirror-only=user1:user2:user3 /home/shared /home/shared
end script
- Adjust the bindfs options and mount point to fit your needs. Save the file and exit.
- Unmount the partition and start the Upstart job to check if it works as expected:
Code:
sudo umount /home/shared
sudo initctl start mount-bindfs
- If something went wrong remove the job file:
Code:
sudo rm /etc/init/mount-bindfs.conf
6. That's all
Copy the files you want to share with the other users in the directory (/home/shared).
Links
http://code.google.com/p/bindfs/
community/FilePermissions
HowTo: Use ACLs
Questions? Suggestions?
Bookmarks