Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Mac OS X has hundreds of configurations and settings to control your environment that you work in. Some of these can be set in your system preferences but others are actually inaccessible to most users. But through Unix we can access those configurations and even modify them. In this movie we'll learn how to do that. Before we begin, keep in mind two things about setting configurations. The first is you want to be super careful that you don't accidentally change a configuration that you didn't mean to change. You might set something into an undesirable state. The second thing is that some changes are going to take effect immediately, but others are going to require either that you log out and back in or that you completely restart your Mac.
So just because you don't see a change right away doesn't mean that it didn't actually take effect. It really just depends at what point the Mac loads in that particular preference, and that's going to vary from preference to preference. Let's start by seeing where the configurations are stored. I'll use Command+N to get a new window in the Finder and I'll open another Finder window here to put next to it, and then this one I'll use Command and click on the bar to go up to Macintosh HD. Now we have a Library folder here and we have a Library folder here. These are where the different configurations are stored.
These are the configurations which are global and apply to every user on the system. these are the ones that are just for me in my particular User. Inside the Library for each of them, there is also a Preferences folder. That's where these are typically stored. Now they may exist in other places in some cases. Here is the Preferences for this one, there we are. But most of the time these are the two places that you'll find them and they really depends on whether the preferences are global preference or user preference. Let's go inside the user one here and let's take a look at this. I'll actually close up the global one. And you notice almost all of these have the same format. The name is always com, period, the company name, followed by the application name, and then typically it ends in plist at the end.
Remember this format because we're going to need to use it. Plist let's you know that it's a preference list. We can open that up in a text document but if we double-click on one, we'll open up the Apple Property List Editor that they give you with your Mac. I've opened up the one is for the Finder. So do the same, just so you can follow along with me. Now what we she here are the keys and values for all the configuration options. So for example the Preferences window location has the following coordinates. My EmptyTrashProgressWindowLocation here will be placed at the following coordinates.
It remembers where we've moved that progress window as the trash is emptied. If we move it someplace else, it keeps track of those coordinates in its preference list and that's why it opens up in the same place every time. Now you can open up a lot of these, your SearchViewSettings, you see what's inside there. RecentFolders, DesktopVolumePositions, ComputerViewSettings, BrowserWindowState, and open up you can dig around and see what's there. If you double-click on something here you can actually change these values. So you can change them directly via the Property List Editor. We're going to do instead is learn to read and write these values directly from Unix without using the Property List Editor, and I'll show you why that's a better solution.
The way that we're going to do that is by using this Unix command called Defaults. It's a program that's a Mac only Unix program that will manage these default settings for us. One benefit is that it takes care of whether or not these are user preferences or global preferences. It goes and finds it in the right place and makes the change for us and we don't have to dig around at all. And after the defaults command we can put several other commands that we want defaults to run. We're going to be looking at read and write. There are few others and you can look at the man pages to see what those are, but read and write are the most useful.
So read the domain and the key that we want to read. That will return the value to us so we know what the current setting is. Or we can set a value by saying defaults write, the domain, the key, and the value. And that domain is typically in the format com.companyname.appname. Remember we just saw that, com.apple.Finder.plist. Well that's typically the domain and it's the same thing as the file name. So for example we can do defaults read com.apple.finder and then we can read CopyProgressWindowLocation and that gives us that same string that we saw in the plist editor right here, 169, 270, and it is a string.
Now we can change that value using write. So now instead of that let's use Ctrl+A to shoot to beginning of line, we'll change this from read to write, and use Ctrl+E to go to end of the line, and now we need to provide a value. So the value here is just going to be a string, which means it's in quotes, and inside there we'll just put 168, 270. Put a space between so it's really formatted the exact same way. Make sure we don't mess anything up. Now we just change that first value from being 169 to 168, essentially one pixel of difference for where that window will be located.
If we go back to the Property List Editor and let's close that up, just open that again, Finder, and now you see that the value is changed. 168, 270. So that's really all there is to it. It's just targeting the preference that you want with the right key name and then either reading or writing a value to it. Now the other thing that's nice about defaults though is that some settings won't be listed. Sometimes even the Config file itself won't exist. It won't even be in the Preferences folder. Defaults will take care of creating those files for you as needed and make sure that they are in the right format and everything.
Now how do you know about these settings and what to change, if you can't go in and see them in the plist files? Well quite honestly, you typically learn about them from the Internet. Word gets out from Mac software developers who know the Mac API really well and they know what these available options are and so then word gets out that this is the way you change something. It spreads on the Internet until people find about the sort of mysterious hidden options that they can then type the commands here into defaults and it will set it for them and create the files as needed. In the next movie we'll take a look at some popular changes.
Get unlimited access to all courses for just $25/month.Become a member