Is there a file or folder on your Mac that you’d prefer to keep under wraps?
Maybe it’s a guilty-pleasure song or movie; perhaps you share your Mac with other users and are sick of them snooping around your folders, or maybe your Mac contains some particularly sensitive files, and you want the added security of knowing that these files won’t be immediately visible the moment anyone opens a Finder window on your Mac.
Whatever your motivation, hiding a file or folder can help keep your most private, sensitive, or downright embarrassing content safe from prying eyes. When a file or folder is hidden, it won’t appear in the Finder, but it also won’t appear in search results such as Spotlight searches.
After completing this article, you’ll know how to hide any file or folder using your Mac’s Terminal, and will know how to uncover previously-hidden items, even if you’ve completely forgotten where these items are located on your Mac.
Hide any file or folder, using Terminal’s chflags
Before you dive in and start hiding files and folders, there’s a few points worth bearing in mind:
- If you want to hide a large number of files, then you can usually save yourself some time by placing them all within the same folder, and then hiding that folder. This will also make your life easier if you need to access some of these files further down the line, as you can simply reveal the folder, rather than revealing each item separately. Alternatively, you can create a folder for each type of file you want to hide, for example you could create a folder of hidden photos, a folder of hidden music, and a folder of hidden documents.
- Put some thought into where you store your hidden files and folders. If you need to access a hidden item at any point, then bringing that item out of hiding is much easier when you know its complete file path and file name.
Once you’ve organised all the items you want to hide and decided where to store them, you can hide this content by completing the following steps:
- Launch the Terminal app, by opening a Finder window and navigating to ‘Applications > Utilities > Terminal.’
- In the Terminal window, type the following command, but do not press the ‘Enter’ key on your keyboard:
chflags hidden
- In the Finder window, navigate to the folder or file you want to hide.
- Drag and drop the file or folder into your Mac’s Terminal. The Terminal should then update with the item’s full file path.
- Now you can hit the ‘Enter’ key.
- Check your Finder window – the file or folder should have disappeared!
If you encounter a ‘Permission denied’ error message when you try to run the ‘chflags hidden’ command, then you’ll need to enter the following command into the Terminal:
sudo chflags hidden
Then, enter your admin password, and you should be able to run the regular ‘chflags hidden’ command without any issues.
Accessing hidden files and folders
Once you’ve hidden a file or folder, chances are you won’t want it to stay hidden forever – at some point you may need to access or edit this content, and you may even change your mind and decide to make these items permanently visible.
In the rest of this article, we’re going to look at several ways that you can coax a file or folder out of hiding.
Making a hidden folder temporarily visible
Assuming that you’re trying to uncover a hidden folder and you know its exact location, you can gain temporary access via your Mac’s Finder:
- Open a Finder window.
- Select ‘Go > Go to Folder’ from the toolbar.
- Type the complete path and name of the hidden folder, for example if you wanted to gain temporary access to a hidden ‘Photos’ folder located inside your Mac’s ‘Documents’ directory, then you’d enter: ‘~/Documents/Photos.’
- Click ‘Go.’
- Your hidden file or folder will now reappear in the Finder. At this point you can interact with its content as normal.
- Once you’ve finished, simply close the Finder window and your folder will return to its previous, hidden state.
Make a hidden item permanently visible
If you want to make a file or folder permanently visible, then:
- Open your Mac’s Terminal.
- Type chflags nohidden into the Terminal, but don’t press ‘Enter.’
- Drag and drop the file or folder in question, into the Finder window.
- Hit the ‘Enter’ key on your keyboard.
This item will now be permanently visible in your Finder, even if you close and then relaunch the Finder window, and will also appear in other locations, such as in Spotlight search results.
Forgot where a hidden file or folder is located?
The techniques we’ve covered so far rely on you knowing the exact location of the file or folder, plus its file name. However, if you can’t quite remember whether you hid an item in your Desktop or Documents folder, or whether it had a PNG or JPEG extension, then all is not lost! There’s still a few different ways that you can uncover this hidden file or folder.
If you have a few ideas about where you might have stashed the item you’re looking for, then you use the Terminal to display a list of all the files and folders located in each directory – crucially, this Terminal output will include any hidden files and folders.
Launch your Mac’s Terminal, and then type the following command, followed by the directory that you suspect might contain your hidden items:
ls -a
For example:
ls -a /Users/jessicathornsby/Documents
Show All Hidden Files and Folders
If you have absolutely no idea where an item is hidden, or you have a list of hidden files and folders that you need to gain access to, then it might be quicker to simply reveal all the hidden items scattered across your Mac, using either a Terminal command or a keyboard shortcut.
To use the keyboard shortcut, open a Finder window and then press the ‘Command+Shift+Period’ keys. At this point all of your previously-hidden items should appear in the Finder as dimmed, transparent icons.
Note that these “hidden” items will continue to be displayed, even if you exit the Finder and then relaunch it, so make sure you re-hide these items when you’re finished, by repeating the ‘Command+Shift+Period’ shortcut.
Alternatively, you can reveal every hidden file and folder across your system, by copy/pasting the following command into the Terminal:
defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder
Press the ‘Enter’ key, then open a Finder window. Your hidden items should now appear as dimmed icons.
To return every item across your Mac to its hidden state, run the following Terminal command:
defaults write com.apple.Finder AppleShowAllFiles FALSE;killall Finder
The Finder will close and then relaunch automatically, at which point your hidden files and folders will no longer be visible.
Add Comment