Want CNET to notify you of price drops and the latest stories?

How to hide files and folders in OS X

You can take advantage of the OS X Finder's ability to hide files to create hidden files and folders of your own.

Topher Kessler MacFixIt Editor
Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.
Topher Kessler
3 min read

The separation of files by user accounts in OS X negates much of the need for hiding files and folders, at least for security purposes; however, there are times when you may still want to hide a file or two.

Unfortunately, hiding a file makes managing it much more tedious, since you can no longer access it directly in the Finder.

The easiest way to manage individual hidden files when you need to access them is to toggle the Finder's ability to reveal hidden files, instead of making specific files visible again. For multiple hidden files, there's an even easier method.

Hidden files in home folders
The drawback to showing all hidden files is that sometimes there can be a lot of them. Screenshot by Topher Kessler

But first, to hide your file. There are two ways to hide files in OS X. The first is to rename them so they have a period as the first character in the file name, and the second method is to set a special attribute on the file called a Finder flag that tells the Finder to not display the file under normal browsing circumstances.

To invoke the Finder flag on a file, perform the following steps:

  1. Open the Terminal utility and type the following text, followed by a single space:
    chflags hidden

  2. Drag the desired file to the Terminal window, which should automatically add the file's path to the end of the command.

  3. Press Return, and the command should run and hide the file.

To undo this process, re-enter the exact same command--you can press the up arrow key in the Terminal to reveal the last command--and change "hidden" to "nohidden" (you will have to use the arrow keys to navigate the cursor).

You can reveal any hidden files in the Finder by running the following command (copy and paste it into Terminal):

defaults write com.apple.finder AppleShowAllFiles True;killall Finder

To hide files again, repeat the command, but change "True" to "False."

While you can use these Terminal commands to reveal hidden files in the Finder, there are some third-party utilities that can do this more conveniently, including Show Hidden Files, MacPilot, and OnyX.

Regularly unhiding and rehiding individual files or toggling the Finder in this manner can be a lot to remember, especially if you wish to regularly show and hide files in different locations on the hard drive. Because of this, an easier way to manage files you wish to keep hidden is to sequester them all in one hidden folder and then show and hide that folder as needed. Here is how to set this up:

Create new folder
Create a designated 'hidden' folder at a desired location on the hard drive. Screenshot by Topher Kessler
  1. Create a folder at the desired location. For example, create a folder called "HiddenSecrets" in your home directory.

  2. Run the procedure above to hide the folder with Finder flags. So, in our example, you would run the following in the Terminal:
    chflags hidden ~/HiddenSecrets

At this point the folder is now hidden, and you have set up a single location that will keep any file within it hidden, so to access the hidden folder you can take advantage of the Finder's "Go to Folder" command:

Finder's Go to Folder command
Go to the parent folder and use the Finder's Go to Folder option to open the hidden directory. Screenshot by Topher Kessler
  1. Open a Finder window and navigate to the parent folder of the hidden directory (in our example this is the home folder).

  2. Select "Go to Folder" in the Finder's Go menu, or press Shift-Command-G.

  3. Enter the folder name in the field (in the case of our example you would enter "HiddenSecrets").

Doing this will show the hidden folder in the Finder without revealing all hidden files on the commputer and without restarting the Finder. You can now copy files to and from the hidden folder. Additionally, the folder will remain hidden, so there is no need to toggle commands to reveal and hide it. Instead, just close the Finder window that is showing the folder and it will disappear until you go to its parent folder and use the Go menu again.

Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.