Need to show hidden files on a Mac? This is pretty common if you find yourself needing to access hidden files on your Mac, like an .htaccess file you downloaded, a .bash_profile, a .svn directory, – literally anything preceded with a ‘.’ indicating it is invisible by default – you can run the below command from the terminal to set hidden files to become visible throughout Mac OS X.
For some quick background to fill in those who don’t know, files that are hidden in Mac OS are determined so by preceding the filename with a single period symbol (.), you can actually make any file hidden by placing a period in front of the name, thus making it invisible to the Finder. Let’s walk through making all hidden files become visible in Mac OS X, regardless of what system software version is on the Mac.
How to Show Hidden Files & Folders on Mac
This changes the default setting of Mac OS X so that Finder always shows all files, including showing hidden files.
- Launch the Terminal app, found in /Applications/Utilities
- Enter the proper command exactly as shown below, choosing for your version of MacOS or Mac OS X:
- Hit the Return key after the command is entered into the Terminal command prompt, that will execute the command and allow the hidden files to become visible in the file system of Mac OS
For showing hidden files and folders in macOS High Sierra 10.13, MacOS Sierra 10.12, OS X El Capitan 10.11, Yosemite 10.10, and OS X Mavericks 10.9, use the following command string to show hidden files:
defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder
For showing hidden files in Mac OS X 10.8 Mountain Lion, OS X 10.7 Lion, Mac OS X 10.6 Snow Leopard, and before, use this defaults command string instead:
defaults write com.apple.Finder AppleShowAllFiles TRUE;killall Finder
Here is what the defaults command string which shows hidden files looks like in the Mac Terminal:
The Finder will refresh after you hit the Return key, which causes Finder to quit and relaunch itself for the changes to take effect, thus revealing hidden files on the Mac.
“Hidden” files are now visible in Finder windows, but they will display as a dimmed version of their respective file icons, being slightly transparent. Examples of how hidden files show up in the Finder are shown below.
This is how hidden files look when they’re visible in a modern version of Mac, like an macOS High Sierra, Sierra, OS X El Capitan or Yosemite Finder window, note the hidden folders and files are visible but have dimmed gray names:
And this is how the once invisible files show in prior releases of Mac OS X, highlighted here:
This setting stays in place until it has been reversed or disabled, which would cause all files to become hidden again just as the default. With all the files visible a Finder window can look much busier than you may be accustomed to, and it’s not always desired to leave on constantly. Thankfully it’s just as easy to switch back.
Remember the Finder must relaunch to show hidden files and folders, they will appear as slightly translucent icons alongside the normal icons. The files and folders that are hidden typically will have a ‘.’ in front of their name, but other items can be hidden as well through chflags commands.
If you’re having difficulty with the above commands for some reason, you can split them up into two parts like so:
First the command to show invisible files on Mac:
defaults write com.apple.finder AppleShowAllFiles TRUE
Then the command to kill and relaunch Finder on Mac, which is where the invisible files will now be shown:
Note that refreshing Finder is always necessary. This is the same in OS X El Capitan, Yosemite and old versions of Mac OS X too, the Finder must always be refreshed this way to reveal the hidden folders and files.
* Quick note about different versions of Mac OS X: If you look carefully, you’ll notice there is a very slight difference in casing for making hidden files and folders visible in modern versions of macOS and Mac OS X versus older versions of Mac OS X system software (com.apple.finder vs com.apple.Finder). That casing is important, however, which is why you must enter exact syntax.
Reverse to Default & Make Files Hidden Again in Mac OS X
To hide files that are intended to be hidden again, thus going back to the default Mac settings of keeping them invisible, you can just type the following defaults command. As you can see, everything is the same except that TRUE has been switched to “FALSE”:
defaults write com.apple.Finder AppleShowAllFiles FALSE;killall Finder
Remember the slight difference in OS X Mavericks, El Capitan, and Yosemite has to do with capitalization:
defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder
Hit return, and again the command will set the file visibility change and relaunch Finder so that it can relaunch for changes to take effect.
That’s all there is to it! The change will revert and you’ll be back to the default with hidden folders and files no longer visible in the Mac OS X Finder.
Show Hidden Files in a Mac Open or Save Dialogue Temporarily
Another approach to without using the above defaults command is to quickly show all hidden files in any Mac OS X Open or Save dialogue box by hitting Command+Shift+Period on the keyboard together. You will instantly see the change as once-hidden files are revealed.
That command sequence can be used to toggle back or forth, thereby revealing and hiding the files again as needed. For many users, this keystroke is the most appropriate use for when an invisible file must be modified but there is no need to make them all visible all the time.
Show Hidden Files & Folders on a Mac Temporarily with Terminal
Another way to quickly see hidden files in OS X is by using the ls command within the Terminal, at the command line type the following:
The -a flag tells the ls (list) command to show all contents, including hidden files. You then just have to specify a directory if you want to see the hidden files in it:
ls -a ~/Sites/betasite
This method does not effect the Finder or the visibility of hidden files outside of using the -a flag, making it a temporary measure to quickly see all contents of any directory or folder, even if the above defaults command isn’t used.
One way to carry over the terminal to the GUI though would be to use the ‘open’ command, directed at a hidden file. Here’s an example:
This will launch the file called “.not_visible_by_default” into the default GUI app associated with it’s file type, in this case it would be a text file and so TextEdit would open. This trick can also be used to open hidden directories into the Finder, for example with the following syntax:
That would launch the hidden “.git” directory in a users home directory into a Finder window, without revealing all other files.