Now and then, advanced Mac users need to work with files or folders that are normally invisible because their names start with a period. This need goes beyond revealing the
~/Library folder, which we wrote about first in “Dealing with Lion’s Hidden Library” (20 July 2011) and covered again in “Colonel Mustard in the Library with the Shift Key” (7 April 2017).
Some Unix-level files and directories start with a period so they are hidden by default, and many apps create such items to hide support files from the user. I currently have 61 files and directories that start with a period at the top level of my home directory, one dating as far back as 2008. That was a file called
.Maelstrom-data that must have been related to the game Maelstrom, a fun blast from the past. Most recently, and the event that was the impetus for this article, I needed to check to see if I had a public key in
Because macOS is based on Unix, you can open Terminal and list all the files in a directory, including the invisible ones, with
ls -asl (only
-a is necessary, but I always use
-asl to get hidden files, file sizes, and a detailed listing).
However, sometimes you don’t want to mess with Terminal, or it would just be easier if you could open one of these files in a text editor by dragging it to the app’s Dock icon. Wouldn’t it be helpful if you could just see these invisible files in a Finder window? You can!
Command-Shift-. and watch your invisible files appear. The shortcut is easy to remember because the period is the character Unix uses to hide files and directories. (Bonus points to those who flinch slightly when typing it because your fingers remember when
Command-. was the universal “stop it!” keystroke on the Mac.)
After you press that keyboard shortcut, all hidden files and directories appear, grayed out so you know they’re meant to be invisible, in all open Finder windows. Despite being grayed out, you can work with them like any other icons in the Finder, double-clicking them, copying or moving them, opening them in an app by dragging to the app’s Dock icon, or even trashing them. It all works. That said, don’t go nuts—you’re not meant to see or interact with these files, so if you don’t know what you’re doing, leave them alone.
(For those who are paying close attention to the screenshots, the difference in what’s showing between the Terminal listing and the Finder window is because
ls puts the files that start with a capital letter together at the top, whereas the Finder doesn’t distinguish between cases when alphabetizing.)
As much as it might sound amusing to work with invisible files showing, they can clutter the display, so just press
Command-Shift-. again to hide them. As long as you remember the keyboard shortcut, it becomes trivial to show invisible files, do what you need, and hide them again, all from the Finder.