Macs also hide files and folders beginning with a . character. There’s also a special “hidden” attribute the Finder will obey. Hiding a file or folder is a bit more difficult on a Mac. Try to rename a file or folder so it begins with a period and the Finder will tell you “these named are reserved for the system.” There’s also no way to quickly toggle the hidden attribute in the Finder’s graphical interface.
You can quickly mark a file or folder as hidden with the chflags command in the terminal. First, open a Terminal window by pressing Command + Space, typing Terminal into the Spotlight search dialog, and pressing Enter.
Type the following command into the terminal, but don’t press Enter:
chflags hiddenBe sure to type a space after “hidden.”
Next, locate the file or folder you want to hide in the Finder. Drag and drop it to the terminal. The file or folder’s exact path will appear in the terminal.
Press Enter to run the command. This will mark the file as hidden.
Use the same command to unhide a file or folder in the future, using “chflags nohidden” instead of “chflags hidden”.
View Hidden Files and Folders on Mac OS X
Mac OS X has a secret keyboard shortcut to view hidden folders and files in any program’s Open or Save dialog. Just press Command + Shift + Period. Note that this only works in Open and Save dialogs — not in the Finder itself. However, this may be the most convenient way to quickly access your hidden files when you need them.The Finder doesn’t have a graphical option for viewing hidden files and folders. Instead, you’ll have to use a command. First, open a Terminal window in the same way as above. Run the following commands on Mac OS X 10.9 Mavericks. These commands will set the Finder to always show hidden files and restart the finder so your changes will take effect. Type each command into the terminal and press Enter after each.
defaults write com.apple.finder AppleShowAllFiles TRUE(On older versions of Mac OS X prior to Mavericks — 10.8 Mountain Lion. 10.7 Lion, and 10.6 Snow Leopard — use the same commands as above but change “com.apple.finder” to “com.apple.Finder” — the F here must be capitalized on these operating systems.)
killall Finder
The Finder will show hidden files. They’ll be partially transparent so you can see which files are hidden and which are normally visible.
To hide files again, run the following commands in a terminal window:
defaults write com.apple.finder AppleShowAllFiles FALSE(On older versions of Mac OS X, remember to use “com.apple.Finder” instead).
killall Finder
To actually prevent people from accessing your secret files and folders, you’ll want to encrypt them instead. Files and folders hidden in the above ways are accessible with a few clicks — they’re hidden from view, but easy to find if someone goes looking for them. Encryption ensures your files and folders can’t be accessed unless someone has your encryption key.