Modifying OS X User Template

For system admins that often require uniform user creation on their machines, it often involves the laborious task of creating users and manually copying files over to each users home folders.

There is, however, a much easier and faster way of automating this task.

When a user is created in OS X, there are a series of default folders being created such as Desktop, Documents, Pictures etc.

how to modify the os x user template

 
It is often the case that you may want to have certain documents, pictures or even preferences uniformly created across all newly created accounts, such as having the Security Policy of the organization as a PDF on the Desktop of every user or a set of Images.

The easiest way of ensuring this, is by modifying the Systems User Template to include that file on the Desktop of every user. To do so, follow these simple steps (Warning: you need to use command line as root user)

The User Template is being picked up from a folder located under:

/System/Library/User Template/English.lproj/

Open Terminal and elevate yourself to root by doing the following:

sudo –s

enter your root password.

Change your directory to the user template folder by:

cd /System/Library/User Template/English.lproj/

NB: The “” in the User Template is not actually a character but a separator in command line, as there is in fact a space between the two words “User Template” and you need to insert “” to inform bash to expect a space in that location. If you do not enter this, it will ignore everything post User and inform you that “bash: cd: /System/Library/User: No such file or directory”

If you list the contents of that folder, you will see the following:

As you can see, these are indeed the default folders created automatically with every user account.

os x user template

 

In our scenario, to add a PDF on the Desktop of every newly created user account, all you need to do is copy the PDF into the Desktop folder inside the User Template folder. To perform this task do the following:

cp /location/of/the/PDF/ /System/Library/User Template/English.lproj/Desktop/

That’s it.

13 Replies to "Modifying OS X User Template"

  • Does this work only for Local users, or does it also work when creating Home folders for “Mobile” Network accounts? Our Macs are bound to Active Directory.

    • Steve

      Yes, it works with network accounts. The system uses the user template to create local user directories on the fly when network accounts log in.

  • Sean

    Mario, this method works for all subsequent accounts that log onto the Mac, including networked accounts such as AD ones.

    It will not apply to an account that logs into the Mac before the User Template is modified

    • Kostas

      Hi Mario,

      As Steve and Sean already mentioned, it will work with all newly created accounts post User Template modification. Both mobile and Network Accounts are fine.

  • Hi guys! Thanks for the replies. I will test it out. Does this method also work for inserting .plist files in the Preferences folder, and other settings in Applications Support? For example, I’d like to pre-load certain default browser preferences and favorites on the Bookmarks toolbars.

    • Alan Lewis

      Yes, it does work for .plist and anything else that is stored in the home directory.

  • Jeremy Spolander

    Just spotted this, Nice one Kostas.

    In theory you could zap the rights on that folder and import a pre-configured home folder with all the right dock icons, settings, app support, prefs, docs etc and then reset the rights after. Any idea if it actually works this way?

    • Kostas

      Hi Jeremy,

      I would love to say yes but in reality it often proves highly unstable. In certain cases application plists, config files and misc pointers/symlinks etc will have hard-coded paths to user locations.

      i.e. an application plist having a key entry pointing to: /Users/username/Documents/folder/../../.

      In those cases there might be issues or even crashes as that location will not be able to be accessed by other users.

      In addition you have cached files that need to be cleaned. The permissions themselves should not be a problem as once you copy the contents of the Template User Folder into User Templates it should inherit the permissions from root folder (root:wheel)

      Hope that helps

  • This method isn’t recommended by Apple, and will frequently get wiped out by OS updates. In fact, this is rumoured to not work at all in an upcoming version of OS X (which I couldn’t possibly comment on). A safer and more future proof method is using a Launch Agent to modify the user’s environment via a script – which will also affect existing users, so you don’t need to worry about copying over new parts of the User Template to them when it’s updated.

  • David Acland

    Hi Dave,

    There’s been a few conflicting reports but most people are saying that as its in the /System folder its going to be locked out with System Integrity Protection.

    The recommended alternatives these days are either configuration profiles or logon scripts depending on what you need to do.

Leave a Reply

Your email address will not be published. Required fields are marked *