This method has been posted all over the place, but I haven’t found a good step-by-step walkthrough that explains how and why to show hidden files on a Mac. As my students frequently ask for it, I’m posting here to keep in the learn section.
Update: there’s an app for that (keep reading…)
Who’s hiding what?
Have you ever noticed the “extra” files that you can see in your FTP client, yet seem to be missing from the local version of the site on your computer? Chances are, those files are on your local computer too, you just can’t see them. Mac OSX (and other operating systems) hide them by default so there’s less clutter, and so you don’t accidentally delete something important.
The most common example that I come across is the .htaccess file, because I work with WordPress frequently. Note how it begins with the period (dot) because htaccess is actually the file extension, not the file name. Most hidden files will begin with a period.
Sometimes when you’re coding for the web, you need to see the .htaccess and other hidden files to change something about your server setup, usually permalink and server configurtations.
Show hidden files on a Mac
To show hidden files, first open up the Terminal app. If you’ve never used this, it’s here:
Applications → Utilities → Terminal
The terminal window that pops up should look something like this, with your hard drive and user name in place of mine.
A quick note before you do anything: using Terminal without knowing what you’re doing can really screw up your computer. It’s not unsafe to do, you just have to be very careful not to type in any commands that you don’t intend to. As such make sure you’ve read the code below carefully and have typed it exactly as written! You have been warned.
Okay now, right after the dollar sign you can go ahead and type or paste in the code below, and press enter.
defaults write com.apple.finder AppleShowAllFiles TRUE
Nothing will happen yet, because you need to restart Finder for the changes to take effect. To do this, you can either press option+command+esc to open the Force Quit Applications window, select Finder from the list and hit “Relaunch”, or simply type in the code below in the Terminal window, and again press enter.
If you typed those lines correctly, your desktop icons should disappear for just a second while Finder restarts and the code in your finder window will look like the image screenshot below.
Now any hidden files on the system should be visible. If you’re not seeing the file you expected, it’s possible that your FTP client is not configured to pull down those hidden files, so you may need to check those settings also. And remember, deleting any system files can break stuff on your computer—if you’re going to go through this process, make sure you’re only editing stuff you know is pertinent to your site, like the .htaccess file.
And, since you don’t want to delete something by mistake, you probably want to hide the files again when you’re done editing your site…
Hide the files again
Back in the Terminal window, we need to basically write the same code again—this time we’re just changing the value of AppleShowAllFiles back to the default of FALSE:
defaults write com.apple.finder AppleShowAllFiles FALSE
Again, you need to restart Finder just like you did before with killall Finder or the Force Quit Applications window. And that’s, that.
Update: there’s an app for that.
I just came across a free, lightweight app called Funter that does this for you, and runs unobtrusively in the task bar. (There were lots of apps that did this previously, but they were neither free, nor lightweight.)
Maybe that’s a better option for some folks.