Show hidden files on a Mac

I often need access to files such as .htaccess when programming, but they are hidden on a Mac by default. Here is a way that you can show/hide them as you wish.

To view hidden files and folders:

  1. Open the Terminal (located in /Applications/Utilities/)
  2. At the command prompt type
    defaults write com.apple.finder AppleShowAllFiles -bool true
  3. Press return to execute the command.
  4. For the changes to take effect, either log out then log back in again, or relaunch Finder (this can be done from the Force Quit Window or by typing ‘killall Finder’ in a Terminal window).

To hide the hidden files again:

  1. Open the Terminal
  2. At the command prompt type
    defaults write com.apple.finder AppleShowAllFiles -bool false
  3. Then press return to execute the command.
  4. Log out then back in again, or relaunch Finder (explained above).