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
    Jan 10 '13 at 19:03
  • Yeah, that's right.
    – Sheldon
    Jan 10 '13 at 19:04
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.