OS X: Hiding Items with the Terminal

| TMO Quick Tip

If you need to keep something hidden from prying eyes, there are a number of ways you could go about it. One great method was described by TMO's own Sandro Cuccia in a recent article on how to use Disk Utility to create containers to keep stuff in. But what if you only need to hide something temporarily, or what if you don't want anyone knowing you've hidden it in the first place? Well, one way you could do it would be to set the file or folder's hidden flag.

Flags are metadata that tell the file system how to interact with an item. For example, when you select something, hit Command-I, and then toggle on the "Locked" checkbox to disable changes to that item, you're actually setting what's called the user-immutable flag.

I can see this if I examine that folder in Terminal:

That "uchg" text informs me that the user-immutable flag is set, so the folder is locked. 

OK, OK. This is all great, you may be thinking, but what does it have to do with hiding files? Well, you can set a hidden flag on a file or a folder, but there's no way to do it through the Finder. You'll have to open Terminal (it's in Applications > Utilities), and here's where I'll mention the usual caveats about being careful with what you type into Terminal. So remember that as we continue, friends.

So once you've got Terminal open, type in the first part of the command to hide something, which is chflags hidden. Make sure you put a space after the second word, then drag in the file or folder you want to hide to make Terminal fill in the path to it:

Afterward, hit Return, and as soon as you do, the file or folder in question will vanish from the Finder as if you deleted it. It'll fool all but the savviest of Mac users!

See? It looks like there's nothing in my folder now, but it's still there. Neat!

To unhide your item, go back to the Terminal. The program saves the last commands you typed, so if you press the Up Arrow until you see your chflags hidden one, you can use the Left Arrow key to move your cursor to the proper place within the command to edit it to chflags nohidden, leaving the path to the item the same.

You can, of course, type in the whole command instead, but this can get a bit complicated with funky path names. Just remember that if your hidden item has spaces or special characters in its name, you'll want to enclose that part of it in quotes, like this:

chflags nohidden /Users/melissa/Downloads/"Path to File.txt"

Anyhow, after you unhide your item, it'll be back where you started as if nothing ever happened.

This method for hiding files is certainly not as good security-wise as creating an encrypted disk image, but with this way, someone who uses your Mac won't know anything was there to begin with. And heck, you could even hide an encrypted disk image itself, so someone would have to find what you'd hidden first and then guess your password to get in. You sly minx.



Melissa, Melissa, Melissa, you are a clever gal. I can just see forgetting that I hid that naughty folder of mine and spending my life hunting it down. Now if the cookie jar could be hid, I’d finally be able to get into that prom suit I wore so long ago.


There actually is a way to hide items easily in Finder without having to go to Terminal. Simply change the name of a file/folder by beginning the name with a period. Once you do this, Finder will warn you that the item will be treated as “invisible”.


One thing missing from the artical is how to list files in the terminal that have been hidden.


So if I were to hide a file or folder, how do I find it again 3 months later when I forget what the file/folder’s name is? Can I do “ls -al” in terminal.app to see even the hidden files?

Melissa Holt

Oh, mhikl. You are just peachy! Never stop commenting.

Johnathan—unfortunately, that’s no longer true for recent versions of the OS. If you try to add a period to the start of a file or folder name under 10.8, for example, it won’t let you do it. See here:


1stplacemacuser, I’m fairly certain that the Terminal command “ls -la” will show even files hidden in the way I’ve described above. I’m on vacation, though, and I don’t have access to a Mac to test for sure. smile Perhaps someone will verify that and report back?

In any case, you can always go back into Terminal and press the Up Arrow key to see previous commands you’ve entered, so if you forget your file’s name, that’d be one way to see it!


Thu Phan

I’m very new to this, but where do you get to the terminal to type that tag in? Please help!

Melissa Holt

Hi there,

Terminal is an application that lives in your Applications folder, in a subfolder called Utilities. Be careful, though; if you’re not familiar with how it works and how to enter commands, it’s easy to make mistakes with unintended consequences. So just tread lightly. grin


Sandra Taylor

Seems to be interesting debate going on here. Well I have to ask mellisa that should I use this command
Open terminal = spotlight search terminal
paste in these lines
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
To hide hidden files just change TRUE = FALSE
I should try applications like this one http://www.showhiddenfilesmac.com/?
Need reply. Thank you.

Alan Martinez

Hey Melissa, can you hide multiple files at once? Or is it only one at a time? Because I have multiple files I want to hide.

Melissa Holt

Hey Alan,

You sure can. You can drag every file you want to hide into the Terminal window, and the same command should work for all of them.

Hope that helps!

Log-in to comment