Results 1 to 10 of 21

Thread: HowTo: Create a shared directory for local users (with bindfs).

Threaded View

  1. #1
    Join Date
    Feb 2007

    HowTo: Create a shared directory for local users (with bindfs).

    The information in this thread has been moved to

    A thread for discussion of the wiki page only can be found here

    Thread closed.

    Before you start

    This guide assumes that you already know:


    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.


    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.

    1. Make sure that the repo is enabled, open up a terminal and run:
      sudo software-properties-gtk --enable-component universe
      sudo apt-get update

    2. Install it:
      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

    1. e.g. in the /home directory:
      sudo mkdir /home/shared
      NOTE: If the directory already exist skip this step.

    2. allow only root to access it, we will set the permissions later with bindfs:
      sudo chown root: /home/shared
      sudo chmod 0700 /home/shared

    3. Setting the permissions with bindfs

    1. Now use the bindfs command to mount the shared directory with altered permissions.

      Syntax of the command:
      bindfs [options] dir mountpoint

      1. example:
      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:
      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:
      man bindfs
    2. To unmount the directory:
      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:

    1. To try out different permissions you have to unmount the directory (3.ii.) then remount it with different permissions (3.i.).

    2. You can use su or sudo to log in as a different user:
      su - username
      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:
    3. You can run the file manager as a different user.

      1. Allow the user to connect to the X server:
      xhost +SI:localuser:username
      2. Run the file manager:
      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:
      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.

    1. Backup the fstab file:
      sudo cp /etc/fstab{,-backup}
    2. Open it in a text editor:
      gksu gedit /etc/fstab
    3. Add an entry at the end of the file. The syntax of an entry:
      bindfs#/path/to/dir    /path/to/dir    fuse    options    0    0

      1. example:
      bindfs#/home/shared    /home/shared    fuse    perms=0700,mirror-only=user1:user2:user3    0    0

      2. example:
      bindfs#/home/shared    /home/shared    fuse    perms=0750,mirror=user1:user2:user3,group=groupX    0    0
    4. Save the file and exit.

    5. Unmount the partition and mount all filesystems mentioned in fstab to check if the entry works as expected:
      sudo umount /home/shared
      sudo mount -a
    6. If something went wrong, restore the original fstab file:
      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.

    1. Create the job file and open it for editing:
      gksu gedit /etc/init/mount-bindfs.conf
    2. Paste the following code into the file:
      # Remount directories with bindfs
      # Temporary workaround until BUG 503003 is fixed
      description "Remount directories with different permissions"
      start on stopped mountall 
        bindfs -o perms=0700,mirror-only=user1:user2:user3 /home/shared /home/shared
      end script
    3. Adjust the bindfs options and mount point to fit your needs. Save the file and exit.

    4. Unmount the partition and start the Upstart job to check if it works as expected:
      sudo umount /home/shared
      sudo initctl start mount-bindfs
    5. If something went wrong remove the job file:
      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).

    HowTo: Use ACLs

    Questions? Suggestions?
    Last edited by nothingspecial; June 29th, 2012 at 09:35 AM. Reason: Added new method for mounting the dir at boot.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts