Learn/Code
Learn

Show hidden files (like htaccess) in Mac OS X

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. 

(Fuggles and alturnwall, respectively. Yes, I name all of my hard drives after hops varietals.)

Screen Shot 2013-08-04 at 10.41.56 PM

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.

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.

Screen Shot 2013-08-04 at 10.49.29 PM

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:

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.

(5/28/2014)
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.

 

20 thoughts on “Show hidden files (like htaccess) in Mac OS X

    • I guess you could use that program too, but why pay the money for the app when you can simply paste in the code above for free? The app does the exact same thing, it just gives you a one-click button to do it. Bookmark this page and paste the code in Terminal when you need it instead 🙂

  1. Is there a way to have hidden files shown in Finder, but not on the Desktop?
    E.g. I’d like to see my .htaccess files in Finder, but I do not want to see the .DS_Store on my Desktop.
    Is this possible?

    • That’s an excellent question Karsten… and I’m not aware of a way to do it. Since “Desktop” is really just a folder in Finder, you’re looking to change settings for ever folder except one, and I’m not sure how to do that.

      But, I just came across this FREE app that toggles the hidden file visibility easily: Funter, and made an update with a link to this in the article above.

      Hope that helps.

  2. You can open it straight from the FTP program. So you download the htaccess file using the FTP program. In my case I use FireFTP for firefox (its free and works great.) Then I can see the .htaccess file in the ftp program. Then I just right click the file I need and choose open…. easy peasy.

    • That’s a great point Daniel. If your FTP program allows it, that’s a great way to go. But, should you download all of the files to a location on your computer and need to access at a later date (or edit for use locally, such as in a testing environment), the above still works.

    • @CloneScriptmania: I can confirm that this method is still working to show HIDDEN files on the latest version of OSX (10.10.1).

      Note that .htaccess is just an example—this method is working if you can see ANY hidden files (for example, you may see .DS_Store on your desktop). If you can see any of those, then this is working, and the issues is just where your .htaccess file went.

      It’s possible that you’re just missing the .htaccess file, or it’s not where you think it should be. If you’re working with WordPress, it’s possible that the file was not previously generated after moving locations. To generate a new file, go to:

      Settings > Permalinks

      Just navigating to that page should do it, but you can “Save Changes” for an extra measure.

      Hope that helps.

      -Alex-

Thoughts, questions or qualms?