Monday, June 9, 2014

Hide & Find Any File On Mac OS X

There’s no straightforward way to quickly hide or reveal hidden files on Mac OS X as there is on Windows – but hide and seek on a Mac is not a particularly hard game to play.

Using a few simple Terminal commands you can quickly hide secrets and reveal system files, as well as seeing what other hidden files and folders have been cluttering up your Mac over the years.

It’s Terminal time.

Marking Files As Hidden


On Windows, you can simply right click on a file and check a box to hide it. This is easily defeated by forcing Explorer to reveal all hidden files, also accessible through the GUI under the View menu. If you’re really serious about hiding something on Windows, you’ll probably want to encrypt it properly – simply hiding a file isn’t enough.

Mac OS X is the same, but there are still instances when hiding a file might come in handy – like quickly removing a file from Spotlight’s index or hiding a folder without moving and causing problems for software that relies on it.

There are simple commands for hiding a file, and these are really no more complex than how Microsoft does things – except you’ll have to use the command line. In order to hide a file, launch the OS X Terminal and type the following:

mv path/to/file path/to/.file

Replace the “path/to/file” with the location of the file or folder you want to hide. This uses the “mv” rename command to rename the file or folder with a “.” preceding it, which is how the Mac OS filesystem (among others) denotes hidden files. To change it back, repeat the command in reverse like so:

mv path/to/.file /path/to/file

This isn’t actually the only way to achieve this, another example would be to use the “chflags” permission command:

chflags hidden path/to/file

To reverse this, simply change “hidden” to “nohidden”. Once you have hidden a file, OS X cannot find it in its default state – Spotlight will ignore it, as will Finder if you browse to that directory. This should be enough to fool non-techies who you simply don’t want snooping around private directories.



Note: If you’re really hopeless and can’t find a file, locate it in Finder and then right click and choose Inspector (or select it and hit Cmd+I) – its full path will be revealed under the “Where” field, as per the screenshot above.

Once you have hidden a file or folder, you will probably want to hide your tracks. Every Terminal command you enter is stored in a buffer, which can be recalled by pressing the up arrow on your keyboard in any open Terminal window.



These commands are not forgotten even when the window is closed, but you can force Terminal to forget them under Edit > Clear Scrollback or using the Cmd+Option+K shortcut. The clear command can also be used to clear the current Terminal window output.

Finding System Files


Spotlight will not reveal hidden files or folders until they are unhidden again – so non-techie friends won’t be able to find your diary or collection of selfies simply by searching. Even if you set Finder to always show hidden files, Spotlight still will not index files marked as such.




You can use Spotlight search to find system files though, so if you have a rogue .kextyou want to delete then you can find it by searching for the file name in Finder, clicking the small plus “+” beneath the search field then choosing “Other” from the Kind drop-down box. This will present you with a lot of options (as seen in the image above) – choose “System files” and hit OK.

You can now search using the box provided for system files, but not hidden files.

Revealing Hidden Files


Finder will not display hidden files by default, and there’s no checkbox to tick as per Windows methodology – you’ll need to use the Terminal again. In order to force Finder to display all hidden files, all of the time, open Terminal and paste the following:

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder

This command affects the whole system, and you will notice annoying “.localized” or “.DS_Store” files on your desktop and in other places – all perfectly normal, and usually perfectly hidden from sight. You can take the opportunity to look for that hidden file, browse system files, clean up folders, delete mess left over from uninstalls before reversing the command by changing “TRUE” to “FALSE” and running it again.

Find Any File


The “all or nothingness” of the AppleShowAllFiles command makes it difficult to work with as a permanent solution – and you still can’t use Spotlight to search for files that are marked as hidden. In this instance, a shareware third party tool likeFind Any File (free trial, $6) can really help.



It ignores the content of your files (that’s what Spotlight indexes – things like email contents, IM history and so on) in favour of analysing file characteristics instead, such as name, date created and similar parameters. For this reason, it perfectly complements Spotlight, and it goes beyond Spotlight’s reach by providing fast access to any file on the drive, regardless of whether it is hidden or not.

Also Consider


Did you know your Library folder is not indexed by Spotlight? If you want somewhere to quickly dump a file that you don’t want indexed and searchable, then the Library is a great place to put it. By default it’s not even accessible on OS X – and most of your friends probably don’t know how to find it either.

To access the Mac OS X Library, open Finder and click Go in the menu bar. Hold the Option key down and click Library when it appears. You can also choose Go To Folder… and input “~/Library” without quotes. Don’t forget to remember what you’re moving, and move the file back once you’re done!

No comments:

Post a Comment