What is the defaults Terminal command?

There are many tips for OS X on the Apple Mac that involve opening a Terminal window and typing an obscure command starting ‘defaults write blah blah…’ Have you ever wondered what it all means? This article demonstrates how to use the defaults command by revealing hidden files that are stored on your iMac’s or MacBook’s disk drive.

The OS X defaults Terminal command is a tool that is used to view and modify the settings for OS X and applications. These settings are stored in .plist files. Many apps have a Preferences menu and the options you set in Preferences are stored in .plist files, but not all the settings in Plist files are available in Preferences. There are hidden secret settings in .plist files.

In Finder, pull down the Go menu then hold down the Option key and click Library. Open the Preferences folder in Library and you will see a large number of files ending .plist. One them is called com.apple.finder.plist and this stores the settings for Finder.

Related: Discover what's slowing down your Mac using Terminal

If you want to see what settings are stored in com.apple.finder, go to the Applications folder, Open the Utilities folder and then run Terminal.app. At the command prompt in the Terminal window, type:

defaults read com.apple.finder

You omit the .plist at the end of the filename because defaults assumes it’s a .plist file. Defaults displays a lot of information and you will need to use the vertical scroll bar on the right side of the Terminal window to view it all. Scroll back to the top as in this screenshot:

Terminal defaults command

Notice that there is a line that says ‘AppleShowAllFiles = FALSE’ at the top. This is a simple setting in Finder. Some of the other settings are much more complicated, so let’s focus on this one. Suppose we wanted to find out the value of just this one setting without the page after page of code we had before. In this case we would enter:

defaults read com.apple.finder AppleShowAllFiles

Defaults reads the com.apple.finder.plist file, searches for AppleShowAllFiles and outputs its value, which is FALSE. One of the functions of the defaults command is to read the value of a setting in a .plist file. In this case com.apple.finder.plist.

Suppose we wanted to change the value of this setting. Instead of defaults read we would use defaults write:

defaults write com.apple.finder AppleShowAllFiles TRUE

Defaults opens com.apple.finder.plist, searches for AppleShowAllFiles and sets the value to TRUE. This particular setting has values of TRUE or FALSE, but other settings can contain numbers.

Here is how a Finder window looks when AppleShowAllFile is set to FALSE:

Finder

It does not show all files and some are hidden, although you may never have realised this. When AppleShowAllFile is set to TRUE and a Finder window is opened, it looks like this:

Notice that there are some files and folders are displayed in light gray. They are hidden files (starting a file or folder name with a dot will hide it). Whether you use the TRUE setting and view all files or the FALSE setting and view just the normal files is up to you. Just use the appropriate defaults command.

Related: Solve Spotlight problems with Terminal commands

 

Share

Add new comment

By submitting this form, you accept the Mollom privacy policy.

Related items you will like...