How to show hidden files on macOS 10.12 Sierra

There are thousands of hidden files on your mac, usually they are hidden because they shouldn’t be meddled with, but there are many cases where you want access those files, especially as a programmer. You might want to edit a .htaccess file or access your user library folder that has been hidden in macOS since OS X 10.7 Lion.

To show all hidden files, open Terminal in /Applications/Utilities/ and run:

defaults write AppleShowAllFiles 1

and then restart Finder by running:

killall Finder

To hide all hidden files, you run the same command, except change the 1 to a 0, like this:

defaults write AppleShowAllFiles 0

Here’s a useful function I made, it will check if hidden files are hidden/unhidden, and will unhide/hide them depending on which state they are in. You can add this to your .bash_profile in your user folder, and run it at any time by running the command hiddenfiles.

hiddenfiles () { if [[ $(defaults read AppleShowAllFiles) == "0" ]]; then defaults write AppleShowAllFiles 1; else defaults write AppleShowAllFiles 0; fi && killall Finder ; }

You can also hide or unhide individual files. To unhide your user Library folder for example, run:

sudo chflags nohidden ~/Library

To hide it again, run the same command except change nohidden to hidden, like this:

sudo chflags hidden ~/Library

Leave a Reply

Your email address will not be published. Required fields are marked *