View Hidden Files and Folders on Your Mac With Terminal

What's Hidden Is Revealed With the Help of Terminal

Terminal command to view hidden folders
Use Terminal to uncover your Mac's hidden secrets. Screen shot courtesy of Coyote Moon, Inc.

Your Mac has a few secrets, hidden folders and files that are invisible to you. Many of you may not even realize how much hidden data there is on your Mac, from basic things, such as preference files for user data and apps, to core system data that your Mac needs to run correctly. Apple hides these files and folders to prevent you from accidentally changing or deleting important data that your Mac needs.

Apple's reasoning is good, but there are times when you may need to view these out-of-the-way corners of your Mac's file system. In fact, you'll find that accessing these hidden corners of your Mac is one of the steps in many of our Mac troubleshooting guides, as well as our guides to backing up important data, such as mail messages or Safari bookmarks. Fortunately, Apple includes ways to access these hidden goodies in OS X, and the more recent macOS. In this guide, we're going to concentrate on using the Terminal app, which provides a command line-like interface to many of the Mac's core functions.

With Terminal a simple command is all it takes to get your Mac to spill its secrets.

Terminal Is Your Friend

  1. Launch Terminal, located at /Applications/Utilities/.
  2. Type or copy/paste the following commands into the Terminal window. Press the return or enter key after you enter each line of text. Note: There are only two lines of text below, each in its own gray box. Depending on the size of your browser’s window, the lines could be wrapping and appearing as more than two lines. This little trick can make it much easier to copy the commands: place your cursor over any word in the command line, and then triple-click. This will cause the entire line of text to be selected. You can then paste the line into Terminal. Be sure to enter the text as single lines.
    defaults write com.apple.finder AppleShowAllFiles TRUE
    killall Finder
  1. Entering the two lines above into Terminal will allow you to use the Finder to display all of the hidden files on your Mac. The first line tells the Finder to display all files, regardless of how the hidden flag is set. The second line stops and restarts the Finder, so the changes can take effect. You may see your desktop disappear and reappear when you execute these commands; this is normal.

    What Was Hidden Can Now Be Seen

    Now that the Finder is displaying hidden files and folders, just what can you see? The answer depends on the specific folder you're looking at, but in just about every folder, you'll see a file named .DS_Store. The DS_Store file contains information about the current folder, including the icon to use for the folder, the location its window will open in, and other bits of information the system needs.

    More important than the ubiquitous .DS_Store file are hidden folders that Mac users used to have access to, such as the Library folder within your Home folder. The Library folder contains many files and folders that relate to specific apps and services that you use on your Mac. For example, have you ever wondered where your email messages are stored? If you use Mail, you'll find them in the hidden Library folder. Likewise, the Library folder contains your Calendar, Notes, Contacts, Saved Application States, and much more.

    Go ahead and look around the Library folder, but don't make any changes unless you're having a specific problem that you're attempting to fix.

    Now that you can see all the hidden folders and files in the Finder (say that three times fast), you'll probably want to hide them again, if only because they tend to clutter up Finder windows with extraneous items.

    Hide the Clutter

    1. Launch Terminal, located at /Applications/Utilities/.
    2. Type or copy/paste the following commands into the Terminal window. Press the return or enter key after you enter each line of text. Note: There are only two lines of text below, each in its own gray box. Depending on the size of your browser’s window, the lines could be wrapping and appearing as more than two lines. Don't forget the triple-click tip from above, and be sure to enter the text as single lines.
      defaults write com.apple.finder AppleShowAllFiles FALSE

      killall Finder

    Poof! The hidden files are once again hidden. No hidden folder or file was harmed in the making of this Mac tip.

    More About Terminal

    If the power of the Terminal app intrigues you, you can find out more about what secrets Terminal can uncover in our guide: Use the Terminal Application to Access Hidden Features.

    Reference

    defaults man page

    killall man page