How to hide files and folders on Mac with Terminal

Learn how to use the built-in Terminal app on your Mac to hide files and folders from prying eyes. And of course, you can also unhide them when the need arises.

Hide files using Terminal on Mac

If you have some top-secret files on your Mac that you want to hide, there’s no switch or setting you can enable. However, there is a Terminal command you can use that lets you hide files or folders.

Once you hide them, they won’t display in Finder, but you can still get to them using their direct path. This keeps those items you want tucked away from plain view, nice and safe.

Also see: How to encrypt and password protect folders on Mac

How to hide files or folders with Terminal

Pop open Terminal using whichever method is easiest for you. You’ll also want to navigate to the location of the file or folder you want to hide. With both on your screen, enter the following command into Terminal but do not hit your Return key yet.

chflags hidden

Be sure to include a space after “hidden.”

Terminal Command Hide File Folder

Then, drag the file or folder from its location to the end of the command in the Terminal window. Now, hit the enter/Return key.

Hide Folder Terminal Mac

You may need to reopen Finder to see the file or folder disappear from view.

Unhide files or folders

If you want to reverse hiding that file or folder later on, this is also as simple as a Terminal command.

First, open Finder and press the Command + Shift + Period keys to show the hidden files.

Hidden Folder Visible Mac

Next, open Terminal and enter the following command with a space at that end, but don’t hit Return yet.

chflags nohidden

Drag the hidden file or folder to the end of the command in the Terminal window and then hit Return. Your secret file or folder will now be visible in Finder once again. If it does not, go to the Force Quit window and relaunch Finder.

Terminal Command Unhide File Folder

There are times when you have files or folders on your computer that you want to make sure no one else sees by mistake. And with a simple Terminal command, you can make it happen quickly.

Is this something that you can see yourself using down the road? If so, let us know!

On a related note: How to hide (and unhide) photos and videos on iPhone, iPad, and Mac