Skip to content
Home » How to Show Hidden Files on a Mac

How to Show Hidden Files on a Mac

There is a keyboard shortcut that shows hidden files in the Finder immediately, and for most people that is the entire answer. What trips people up comes after: some files stay out of sight even with hidden files showing, and other files that the Finder hides turn up perfectly visible in the Terminal. That is not inconsistency — macOS hides files in two completely different ways, and only one of them involves a dot at the front of the name.

The keyboard shortcut

  1. Open a Finder window and go to the folder you want to look at.
  2. Press Shift-Command-Period (⇧⌘.).
  3. Hidden items appear, dimmed so you can tell them apart from ordinary files.
  4. Press the same combination again to hide them.

It is a toggle, it applies to every Finder window at once, and it survives until you toggle it back. It also works in Open and Save dialogs, which is the situation where people most often need it — picking a file out of a folder an app will not show them.

One caution before you go looking. Most of what appears is configuration that applications rely on: .DS_Store files holding Finder’s per-folder view settings, .git directories, dot-files holding shell settings. Nothing there needs tidying, and deleting things because they look like clutter is how people break applications they were not thinking about at the time. Turn the display on to find something specific, then turn it back off.

Make it permanent

The shortcut already persists across restarts, so a permanent setting is only worth it if you want the state fixed by script — setting up a new machine, or a shared configuration. The Finder reads a preference called AppleShowAllFiles:

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

The killall Finder is not optional and not dangerous: the Finder re-reads its preferences on launch, and macOS restarts it immediately. Swap true for false to reverse it. To check the current value:

$ defaults read com.apple.finder AppleShowAllFiles
The domain/default pair of (com.apple.finder, AppleShowAllFiles) does not exist

That message is the normal state on a Mac where the preference has never been written — the key does not exist until something sets it, and the Finder falls back to hiding. It is worth knowing because a script that reads the value has to handle “absent” as well as true and false.

Getting to the Library folder

The single most common reason for wanting hidden files is the Library folder inside your home folder, where applications keep their settings and support files. Two quicker routes exist and neither needs anything toggled:

  • Open the Go menu in the Finder and hold Option. Library appears in the list while the key is down.
  • Or press Shift-Command-G and type ~/Library.

Worth noticing that this folder does not start with a dot, and yet the Finder hides it. That is the first hint that something other than the name is at work — which is the next section.

Seeing them in the Terminal

In the Terminal the equivalent is ls -a. Here is a folder holding three files — one ordinary, one whose name starts with a dot, and one that has been marked hidden a different way:

$ ls
flagged.txt
visible.txt
$ ls -a
.
..
.dotfile.txt
flagged.txt
visible.txt

-a adds the dot-file, along with . and .., the entries for the current and parent directories. If those two are noise, ls -A shows everything except them. Combine with -l for the long listing: ls -la is the form most people end up typing from memory.

Now look again at that first listing. flagged.txt is hidden in the Finder, and it appeared under plain ls with no flags at all.

Why “hidden” means two different things

macOS has two independent mechanisms for keeping a file out of sight, and almost every write-up on this subject describes only the first.

A name that starts with a dot. This is the Unix convention, honoured by both the Finder and the shell. The Finder knows it well enough to warn you if you try it — rename a file to start with a dot and it asks “Are you sure you want to use a name that begins with a dot ‘.’?”, explaining that “The system treats items with these names as invisible files.”

The hidden file flag. This is a per-file attribute stored in the filesystem, nothing to do with the name. The Finder respects it; ls ignores it completely. To see it you need ls -lO, which adds a column of file flags:

$ ls -lO
total 0
-rw-r--r--@ 1 osxhub  wheel  hidden 0 20 Jul 20:30 flagged.txt
-rw-r--r--@ 1 osxhub  wheel  -      0 20 Jul 20:30 visible.txt

The user name in that listing is redacted; nothing else is changed. One file carries hidden in the flags column, the other carries - for none. That is the whole difference, and it is invisible in every listing that does not use -O.

Which brings us back to the Library folder. It has no dot, so by the first mechanism it should be visible — and under the second it is not:

$ ls -ldO ~/Library
drwx------@ 101 osxhub  staff  hidden 3232 30 Jun 17:50 /Users/osxhub/Library

There it is: hidden, applied as a flag to a normally-named folder. This is why ls ~ lists Library quite happily while the Finder pretends it is not there, and why no amount of looking for a leading dot explains the behaviour. Apple hid it this way deliberately when it stopped wanting people to browse it casually, without renaming a folder that decades of software refers to by name.

Hiding and unhiding your own files

chflags sets and clears that flag, and it works on your own files without sudo:

chflags hidden ~/Documents/notes
chflags nohidden ~/Documents/notes

Add -R to apply it through a directory tree. The change takes effect in the Finder straight away, no relaunch needed.

This is the better of the two options if you want something out of the way, because renaming a file to start with a dot changes the name that every other program uses to find it. The flag leaves the name alone. It is also easy to forget you set it — a folder that vanished from the Finder and still shows up in ls is almost always this, and ls -lO confirms it in one command.

What neither mechanism is: security. Both are display conventions. Anyone with access to the account can list, read, and copy a hidden file exactly as before, and a hidden folder full of documents is one ⇧⌘. away from being an ordinary folder full of documents. If the point is that other people should not read something, that is a job for permissions or an encrypted disk image.

Quick reference

GoalHow
Show hidden files in the Finder⇧⌘. (toggle)
Open the Library folderGo menu with Option held, or ⇧⌘G then ~/Library
Set it permanentlydefaults write com.apple.finder AppleShowAllFiles -bool true then killall Finder
List hidden files in the Terminalls -a, or ls -A to skip . and ..
See which files carry the hidden flagls -lO
Hide or unhide a file yourselfchflags hidden / chflags nohidden

So: ⇧⌘. for a quick look, ls -a in the Terminal, and ls -lO when the two disagree about what is hidden. That last case has one cause — a file flag rather than a dot — and once you know it exists, the Library folder stops being a mystery.

Leave a Reply

Your email address will not be published. Required fields are marked *