Type in the terminal:
defaults write com.apple.finder AppleShowAllFiles -bool false
//此命令关闭显示隐藏文件
Change the false above to true:defaults write com.apple.finder AppleShowAllFiles -bool true
此命令显示隐藏文件
You need to reload the Finder after the command is run.
You can option+command+esc, select Finder, and restart. Or find the Apple icon in the upper left corner and choose Force Quit. You can also reopen it.