How to Show and Hide Hidden Files on Mac OS X

If there are hidden files on your Mac computer that you need to access, you can make them visible at any time using a single command in Terminal. This quick, straightforward bit of code instructs Finder to display all files and folders, including those that were meant to be hidden from view. In OS X Yosemite, the command takes effect immediately. In earlier versions, like OS X Mavericks, you may need to relaunch Finder before the hidden files become visible.

...
Open OS X hidden files and folders with a simple Terminal command.
credit: Image courtesy of Apple.

Step

Close all the Finder windows. Launch Terminal by pressing "Command-Space" to open Spotlight. Type "terminal" in the Search field and press "Return."

...
Launch Terminal.
credit: Image courtesy of Apple.
...
Type "defaults write com.apple.finder AppleShowAllFiles YES."
credit: Image courtesy of Apple.

Step

Type "defaults write com.apple.finder AppleShowAllFiles YES" in Terminal and press "Return." This command directs Finder to show all files, whether they are hidden or not.

...
Hidden files and folders are now visible in Finder.
credit: Image courtesy of Apple.

Step

Launch a new Finder window by clicking the "Finder" icon in the Dock. If you are using OS X Mavericks or earlier, you may have to manually relaunch Finder before you can see hidden files. To do this, hold the "Alt" key while right-clicking the Finder icon in the Dock and select "Relaunch." Hidden files and folders are grayed out; however, they are now visible and accessible.

...
Use "NO" in Terminal to hide files that were meant to be hidden.
credit: Image courtesy of Apple.

Step

Hide the hidden files again by using the same line of code with "NO" at the end, instead of "YES." Type "defaults write com.apple.finder AppleShowAllFiles NO" and press "Return."

...
Hidden files are no longer visible in Finder.
credit: Image courtesy of Apple.

Step

Open a new Finder window to verify that the hidden files and folders are no longer visible. If you still see them using OS X Mavericks or earlier, relaunch Finder by Alt-right-clicking the Finder icon in the Dock and selecting "Relaunch."