Close this search box.

Getting Started with Terminal: Hide Files on macOS

mac os terminal commands hero

Table of Contents

Your Mac has a few built-in ways to hide files on macOS from Finder windows. This will make the file invisible until you choose to reveal it or turn the invisibility off. Keep in mind that this doesn’t remove the file from your system or encrypt it.

What does it mean when you hide files on macOS?

When you hide files on macOS, you set a special attribute that makes it invisible to Finder. Even if you navigate into the Finder window where the file should appear, you won’t see the file. It still exists, but it’s just not visible. This attribute can be applied to both files and folders. We must reiterate, however: this provides no security at all. It’s more like tucking something in a particularly obscure drawer. By the end of this guide you’ll learn how to reveal all hidden files on the system, providing a first-hand look at how little security a hidden file provides.

Set the Hidden Flag in Terminal

1. Open Terminal from /Applications/Utilities/ If you’re not comfortable with how Terminal works, you might want to review our guide for getting started with Terminal.

terminal introduction


2. In the Terminal window, copy and paste the command below, imitating the screenshot.

chflags hidden

hide files on macOS chflags hidden

However, don’t press Enter yet. We still need to do a little more before we can execute our command.

3. Open a Finder window and navigate to the file or folder you want to hide. Here, I’ll be hiding a generic folder I’ve created for the purposes of this demonstration. Grab this folder from Finder and drag it into the Terminal window. This will automatically insert the correct file path, including any kind of “escaping” to handle spaces and special characters. It’s far easier working this way versus finding and then typing out the path to the folder by hand.

hide files on macOS copy path in terminal from finder

4. Now we’re ready! Once the path appears in the Terminal window, press “Enter” to set the hidden flag.

hide files on macOS

Removing the Hidden Flag

Of course, we also need a way to remove the hidden flag if we decide we want to reveal the file. Before we do that, we will need to reveal all hidden files (see below). Then, we’ll want to repeat the process above, but change hidden to nohidden instead. Then drag the file you want to unhide into the Terminal window to copy the path and press Enter.

Hide with a Period

As suspected, there is more than one way to skin this hiding files cat. We can also hide files by putting a period at the beginning of the file name. Try to do that in Finder, though, and you’ll be warned off.

hide files on macOS dot notation

If you insist on denying the system’s obvious preference, you can add a period to the beginning of the file name in Terminal. This is called “dot notation,” and it’s the most old-school way of hiding files. As a result, it’s also the best supported. Every single Mac and Linux system under the sun will hide a file that starts with a period, regardless of computer’s age or its operating system version. As a result, dot notation is extremely robust and reliable.

1. Open Terminal as before.

2. Use the cd command in Terminal to change your working directory to the folder containing the files you want to hide. You’ll find more instructions on using the cd command in our Terminal guide.

3. We will use the move command (mv ) to rename these files forcible. The system considers renaming to be a type of moving, switching the contents from one filename to another. The behind-the-scenes stuff doesn’t really matter, but it’s interesting.

We will use the move command like so to rename our file starting with a dot. The first file name in that command (myfile.txt) is the name of the file that currently exists. The filename after the space is the one that starts with a period, which is what we want to change the file name to. So copy and paste this command, changing the filenames as appropriate.

mv myfile.txt .myfile.txt

It doesn’t look like much, but this will immediately hide the file.

Reversing the process is extremely simply. Go back to that directory to Terminal and rename the file by removing the period, as seen in the example below.

mv .folder folder

Revealing Hidden Files in Finder

It’s not much good to hide our files if we can never reveal them. We may have well as just deleted them, in that case! We can use both Terminal and a Finder keyboard shortcut to reveal all hidden files. The behavior toggles for the whole system, revealing your hidden files will reveal all the hidden files. And if this is your first time revealing hidden files, you’re about to discover just how many of them there are on your system. Your user directory, for example, is positively littered with application and system related hidden files which you don’t want to go monkeying around in.

Advanced readers will be well aware that ls -l will reveal all the hidden files within a working directory in Terminal. You can also employ Finder’s “Go to Folder” command in the Go menu to navigate directly to a hidden folder, provided you know the fully-qualified path.

With Terminal

In Terminal, we can set a system-wide flag that will reveal hidden files within Finder. It will be on until we turn it off.

Warning: this method will reboot Finder. If you see the desktop disappear for a moment, that’s to be expected. Make sure you’re not moving, copying, transferring or downloading any files or before you run the command below.

1. Open Terminal as before.

2. Copy and paste the command below into your Terminal window and press Enter.

defaults write AppleShowAllFiles TRUE ;killall Finder


Finder will now restart, as mentioned above. If you were doing anything with Finder, that operation just got cut off rather abruptly.

When you want to turn the toggle off and rehide the hidden files, just change the TRUE property the last command to FALSE. You can copy and paste the command below into Terminal and press Enter to rehide hidden files.

defaults write AppleShowAllFiles FALSE ;killall Finder

With Finder

While this is a guide on Terminal, it would be remiss to not mention the WAY easier method of toggling hidden files: a simple keyboard shortcut.

With a Finder window in the foreground, press Command + Shift + Period. This will reveal all hidden files. If this doesn’t work, make sure you see “Finder” at the left of the menu bar. If not, click on a Finder window to bring the application into the foreground.

When you want to put hidden files back where they came from, press Command + Shift + Period again.

You can toggle this off instantly and system-wide, all without restarting Finder. It’s by far superior, and much preferred by experts. It’s a good shortcut to commit to memory.


So why hide files? It’s a tool that developers use to obscure files from users. Basically, developers don’t want to give unsophisticated users full and easy access to their entire application. First of all, it’s totally unnecessary. Secondly, users are very likely to mess up the developer’s hard work. And thirdly, seeing system files clutter your system is ugly, and macOS is all about keeping thing streamlined and attractive. So hiding files isn’t about securing them: it’s about keeping them out of view, like sticking them in an obscure drawer to keep your grand kids from getting Starbursts between the pages of your TPS reports.

You might also like the following posts:

Getting Started with Terminal: An Introduction

Getting Started with Terminal: Must-Know macOS Terminal Commands

Getting Started with Terminal: Using Grep to Search Files

Kossi Adzo

Kossi Adzo

Kossi Adzo is a technology enthusiast and digital strategist with a fervent passion for Apple products and the innovative technologies that orbit them. With a background in computer science and a decade of experience in app development and digital marketing, Kossi brings a wealth of knowledge and a unique perspective to the Apple Gazette team.

Leave a Reply

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

Related Posts