How to create common folders for all users in Linux

There are occasions, where you need to share certain folders from your home directories with other users on the same machine.

Let's say you and your dad are sharing a computer and each of you have your own accounts, but you both want to listen to the same music. Instead of copying your music directory to his home directory, you can do the following:

Create a new folder somewhere in system file. I chose media:

  • sudo mkdir /media/music/
  • Change the permission:

  • sudo chmod -R 777 /media/music/
  • Simply mount your music on your home directory to this folder:

  • mount --bind /home/username/music/ /media/music/
  • You need to run this command whenever you boot the computer. The best way is to add this command to /etc/rc.local in most Linux distributions.

    Cheers,

    Published On: Nov. 5, 2009 --- Views: 1033

    Tags: linux common directory share


    There are 2 comment(s):

    On Aug. 23, 2010, j says:

    Are symlinks not an option? Usually I do "ln -s /media/music /home/user/music" instead. Also, the proper place for a mount is in /etc/fstab.

    On Aug. 23, 2010, Mohammad says:

    With symbolic links all the files will have the same permissions. So if you cannot regularly access a directory in someone else's home directory, creating a symlinks to that directory won't enable you to access those files, unless you give them permission.


    | More

    Back To The Blog Page

    All Rights Reserved
    Powered By Mohammad Mohtasham