Show hidden files on macOS Sierra & newer

Solution 1:

Session

This keystroke toggles between show & hide the hidden files:

Cmd ⌘ Shift ⇧ . (that’s a FULL STOP, period character)

Press again to toggle back and forth.

When you reboot your Mac, the hidden files will be hidden. Press the keystroke again to show.

Persistent

In Terminal.app, paste:

defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder 

This changes the default setting to show hidden files. And this causes the Finder to restart, so you can see the effect. This new setting persists even after rebooting your Mac.

To revert to hiding again the hidden files, change that true to a false and run again in Terminal.

Solution 2:

I would go about this a little differently. This assumes you want hidden files to always be shown everywhere (in the Finder and also in application's open and save panels).

First, I usually try to avoid killing apps and prefer to tell them to quit. While that is possible using AppleScript in Script Editor, this one-liner will help to solve this problem by adding a Quit menu item to the Finder:

defaults write com.apple.finder QuitMenuItem 1; killall Finder

To undo that you can use either:

defaults delete com.apple.finder QuitMenuItem

or:

defaults write com.apple.finder QuitMenuItem 0

This will now allow you to quit the Finder like any other app.

Second, to show hidden files for all apps (including the Finder), you set the AppleShowAllFiles setting in the global domain.

defaults write -g AppleShowAllFiles 1

To have those settings take effect, quit and relaunch the application you were using (including the Finder).

If you'd like to undo that, run either of the following:

defaults delete -g AppleShowAllFiles

or:

defaults write -g AppleShowAllFiles 0