Show hidden files
1. Open the terminal and type the following command and press enter
defaults write com.apple.Finder AppleShowAllFiles YES
2. Reopen the finder. (hold alt key and right-click on the finder, hit relaunch)
hide hidden files
Follow similar steps as above, just instead of YES put NO, i.e.,
defaults write com.apple.Finder AppleShowAllFiles NO