HOWTO: Have Multiple Users Share an iTunes Library on One Machine

I recently purchased a new MacBook (never having owned a Mac before), and have been reading up on keeping things secure. Per one of those security-related suggestions, once everything was set up to my liking, I stopped using the admin account for everyday use and started forcing myself to log in as a regular user. I’ve also created a user account for my live-in girlfriend so she can go wild customizing her desktop with pictures of flowers, Hugh Jackman, Hugh Jackman laying in a bed of flowers, and so on, without making my eyes bleed.

The trouble is, we both buy music from iTunes on a regular basis using our own individual Apple ID accounts, and there isn’t an easy way to share our music seamlessly with one another. We have similar tastes in music and we’d like it so that when one person buys a new song, it is immediately available for the other person to listen to. Ideally, we’d also be able to create our own unique playlists and assign ratings to the various songs to reflect our own personal likes/dislikes. This article lays out the details of how I accomplished that goal…

The Problem

The main problem with assigning two iTunes Libraries to the same location comes down to permissions. By default, when you download music through iTunes, it assigns permissions based on the user that’s logged in. It only allows that user and people in the UNIX group “wheel” to read the music file (if you’re UNIX-literate, that means it has 640 file permissions). Since a different user (in this case, my girlfriend) would not fit into those categories, she doesn’t have the proper permissions to read any of the music I download. To put it simply…music needs to be world readable.

The Solution

These permissions can be easily fixed by running a simple script that uses the chmod command to modify your music so anyone can play it. To give you a breakdown, the script runs a few safety checks to ensure that you have the proper permissions to modify the files, it then checks that your specified library actually exists, and then it recursively looks at all of your music making sure it is world readable.

The trick is getting the script to run only when necessary as not to waste resources. You could set up a cron job, but then it would have to run on a fixed time table. Either it would run more often than necessary, or not often enough…so cron is out. You could set up a launchd/launchctl configuration file and specify it to run when your Library folder is modified, but unfortunately that doesn’t get triggered when a sub-folder gets modified…so launchd is out.

The key ends up being something called a “LoginHook” that is configured in the /etc/ttys file. Creating a LoginHook will ensure that whenever any user logs in to the machine, the script will be run and proper permissions will be set on the entire library.

Putting it All Together

This should go without saying, but I’m saying it…back up all of your music files before doing anything else! Once that’s done, proceed with the following steps:

  1. First you must pick a centralized location that all your users have access to and make sure the directory exists. I picked /Users/Shared/Music/iTunes and created it on the command-line using:
    mkdir -p /Users/Shared/Music/iTunes
  2. Next, you must adjust your iTunes settings to point to the new location. You do this by launching iTunes, then navigate to iTunes » Preferences… » Advanced, and under the General tab, click the Change… button next to the “iTunes Music folder location” box. Navigate to your newly-created centralized folder (in my case /Users/Shared/Music/iTunes), and click Choose.
  3. For ease of maintenance and to prevent duplicate files from being generated, make sure the checkbox labeled “Copy files to iTunes Music folder when adding to library” is not selected (this is also under the Advanced section of the Preferences dialog box).
  4. Click OK to accept the changes you made to your preferences.
  5. To copy your current library to the new location, navigate to Advanced » Consolidate Library… then proceed by clicking Consolidate. This step only needs to be performed one time per user to ensure that everything gets moved over to the new location.
  6. Repeat these configuration steps for all users that you wish to consolidate libraries for.

At this point, you’ve done all that is necessary to do within iTunes, and all that is left is fixing the file permissions. To do that, log in as a user with administrator privileges and follow these steps:

  1. Download the script and put it anywhere you want. I made another directory called /Users/Shared/bin/ and put the script there, but the location doesn’t really matter.
  2. Modify the script’s LIBRARY variable (in the CONSTANTS section) to point to the centralized music directory you created above.
  3. Ensure that the script is executable by running:
    $ chmod 755 /Users/Shared/bin/share-itunes
  4. Then edit the /etc/ttys file with your favorite text editor, and change the line starting with “console” to add:
    -LoginHook /Users/Shared/bin/share-itunes
    right after the “loginwindow” declaration. Make sure you actually point it to the location where you downloaded the script to. The line should have looked something like this before you edited it:
    console "/System/Library/CoreServices/" vt100 on secure onoption="/usr/libexec/getty std.9600"
    …and look like this after you edit it:
    console "/System/Library/CoreServices/ -LoginHook /Users/Shared/bin/share-itunes" vt100 on secure onoption="/usr/libexec/getty std.9600"
  5. Save the file, and close your text editor.

That’s it! Everything should be all set to go and your permissions will be checked each time you log in to the computer.


The only thing I wasn’t able to automate was adding new music purchased by my girlfriend in to my library so it actually shows up when I launch iTunes. For all I know, there may be an easy way to automate it, but I haven’t found one at this time. Luckily it’s a fast/easy procedure to do by hand…

To actually have new music purchased by another user show up in your library, all you have to do is launch iTunes, go to File » Add to Library…, then navigate to your shared music folder and click Choose. It will take a few seconds to parse through your library, but after it’s done, all of the music should be available for you to play. You will have to do that every time you know that music has been added by another user, but everything else should be automated for you.

Why it Works

Unless you get tricky, iTunes always stores your album artwork, playlists, and song rating information in a file under your home directory (well, in ~/Music/iTunes, to be precise). It also stores a meta file with information regarding what it thinks should be included in your library. These files will be unique to the user even if you choose to share your actual music collections. So when you update your iTunes preferences to move the location of your Library, you still retain the ability to have all your own custom settings regardless of what other users add to the common music folder.

By periodically telling iTunes to add the common music directory in to your library, you’re simply forcing it to update the library meta file so it reflects whatever actually exists in that directory…regardless of whether or not you were the person to purchase the music.

Hopefully these steps will be able to help someone else out there having a similar issue. When I first started looking in to how to accomplish this configuration, I though surely it would be easy and done before, but alas, things got a bit more complicated than I had hoped. If you know of a better way, please do leave a comment and let us know what works for you. If you have any trouble understanding these procedures or getting it to work, let me know and I’ll see what I can do to help out…happy listening!

— Aaron Bull Schaefer