6

What is the easiest/quickest way to share files among different users?

I would like each user to have access to the same music and pictures directories. Creating symbolic links seems tedious as I would have to manually add them after I created each user.

Is there a way to automatically create links to these directories for each user?

2
  • I presume you mean users on the same machine, right?
    – Flimm
    Commented Jan 10, 2013 at 19:03
  • Yeah, that's right.
    – Sheldon
    Commented Jan 10, 2013 at 19:04

1 Answer 1

7

You could write use below mentioned shell script to create links for those directories for existing users and could use skel so that links are automatically created when new users are added.

#!/bin/bash

# GENERATES ALL THE USER HOMES
USERSHOMES="$(cat /etc/passwd | grep home | grep -v /bin/false | cut -d: -f6)"

# THIS IS THE LINK NAME
LINK="music-dir"

# LINK DIRECTORY TO ALL HOMES
for h in $USERSHOMES
do

   # WHERE YOU WANT TO COPY TO
   _dir="${h}/Desktop"
   if [ -d "$_dir" ]
   then
      ln -s "/media/music" "$_dir/$LINK"
   fi
done  

Tested on my system.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .