Software & OS

How to Show Hidden Files on a Mac (Finder Shortcut and Terminal)

To show hidden files on a Mac, open a Finder window and press Command-Shift-Period (⌘⇧.); hidden files appear dimmed, and the same shortcut hides them again. In Terminal, ls -a lists hidden files in any folder.

What counts as a hidden file on macOS

macOS hides two kinds of item:

  • Names starting with a period, such as .zshrc, .gitignore, .ssh or .DS_Store. This is the Unix convention, and Apple's developer documentation notes that a resource "hidden because its name begins with a period" stays hidden whatever its hidden attribute says.
  • Items macOS marks as hidden even though their names look normal, using a hidden attribute. Your ~/Library folder is the one most people go looking for; system folders such as /usr and /etc are also kept out of Finder's view.

Both kinds show up with the methods below.

Method 1: the Finder shortcut (Command-Shift-Period)

  1. Open Finder and go to the folder you want, for example your home folder (Shift-Command-H).
  2. Press Command, Shift and . (full stop) together.
  3. Hidden files and folders appear, slightly faded so you can tell them apart.
  4. Press the same keys again to hide them.

Apple doesn't list this shortcut in its Mac keyboard shortcuts article, but it is built into Finder and you can check it yourself in two seconds. If it seems to do nothing, click inside a Finder window first so Finder is the active app.

Method 2: list hidden files in Terminal (ls -a)

Open Terminal (Applications > Utilities > Terminal) and run:

ls -a ~

-a writes out all directory entries, "including those whose names begin with a <period>", as the POSIX standard for ls puts it. Two useful variants:

ls -la ~       # long format: permissions, owner, size, date
ls -A ~        # like -a but without the . and .. entries

Example output of ls -A ~ on a typical account (trimmed):

.DS_Store   .ssh        .zprofile   .zsh_history  .zshrc
Desktop     Documents   Downloads   Library       Pictures

ls always shows Library; the hidden flag only affects Finder.

Method 3: open a hidden folder directly

You don't have to reveal everything just to get into one folder.

  • Your Library folder: in Finder, hold the Option key and open the Go menu. Library appears in the list only while Option is held.
  • Any path: choose Go > Go to Folder (Shift-Command-G) and type a path. Apple's examples are /Library/Fonts/ and ~/Pictures/. This works for hidden locations too, such as ~/.ssh, /usr/local or /etc.
  • From Terminal: open ~/.ssh opens that folder in a Finder window.

To edit a system file such as /etc/hosts, use Terminal; see how to edit the hosts file.

Method 4: show hidden files permanently

The shortcut is quick, but some people want hidden files always on. Finder has a preference for that, set from Terminal:

defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder

killall Finder restarts Finder so it reads the new setting; open Finder windows close and reopen. To go back to the default:

defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder

Apple doesn't document this preference on its support site, so treat it as something that could change in a future macOS release. The Command-Shift-Period shortcut toggles the same view.

How to hide a file or folder yourself

Two ways, matching the two kinds of hidden item:

chflags hidden ~/Desktop/private-notes      # set the hidden flag
chflags nohidden ~/Desktop/private-notes    # clear it again

chflags comes from BSD Unix, where hidden sets the "hidden file attribute" and prefixing a flag with no clears it. Add -R to apply it to everything inside a folder.

The other way is to rename the item so it starts with a period, for example mv notes.txt .notes.txt.

Hiding is not security. Anyone using your account can reveal the file with the shortcut above, and ls -a shows it. Use encryption for anything that has to stay private.

Hidden files you'll commonly see

NameWhat it isSafe to delete?
.DS_StoreFinder's per-folder view settings (icon positions, sort order)Yes; Finder recreates it
.zshrc, .zprofileYour zsh shell settings, including PATH changes from tools such as HomebrewNo, unless you want to reset your shell setup
.sshYour SSH keys and configNo; you would lose access to servers that use those keys
.gitThe full history of a Git repositoryNo; deleting it turns the folder back into plain files
.TrashYour Trash contentsEmpty the Trash instead
~/LibraryApp preferences, caches, containers and support filesOnly specific items you understand

If you're hunting for what's using disk space, hidden folders such as ~/Library/Caches are often part of the answer; see how to find large files for commands that include them.

Frequently asked questions

Why are some files hidden on a Mac?
Mostly to protect them and reduce clutter. Configuration files such as .zshrc and folders such as .git or ~/Library hold settings that apps manage themselves, and deleting or editing them by accident can break things. macOS hides any file whose name starts with a period, plus files carrying a separate hidden flag.
Is it safe to delete hidden files on a Mac?
Only when you know what the specific file is. .DS_Store files just store Finder view settings and are recreated automatically. Files in ~/Library, dot-folders in your home folder and anything in system folders can hold app data, preferences or license information, so leave them unless you have a specific reason to remove one.
How do I see hidden files on a USB drive or SD card from a Mac?
The same way: open the drive in Finder and press Command-Shift-Period, or run ls -la /Volumes/DRIVENAME in Terminal. Any dot-files macOS wrote to the drive will be listed too.
Why does Command-Shift-Period not work?
Make sure a Finder window is active, not the desktop with another app in front, and press all three keys together: Command, Shift and the full stop key. Some non-US keyboard layouts put the full stop on a different key or need an extra modifier; in that case use the Terminal method instead.

Sources