Hiding and unhiding folders in Windows is pretty easy. You get an option in Folder options in Explorer. You don’t have any such thing in Mac’s Finder and that’s why you got resort to Terminal commands for it.
Hiding and revealing folders
Like I said, you got to use Terminal for this, so open Terminal.app from Launchpad or search on Spotlight.
Once it’s open, paste this command and hit return.
defaults write com.apple.finder AppleShowAllFiles -bool true
This will reveal all hidden folders in your Mac. But you won’t see the results yet. You need to restart Finder to see the effect. To restart Finder, enter this command into Terminal.
You’ll now be able to see the hidden folders and files, their icons look faded and little different from normal folders/files.
To revert back, or hide folders – enter the same command you entered in the beginning, changing TRUE to FALSE, that is:
defaults write com.apple.finder AppleShowAllFiles -bool false
You need to enter
killall Finder again to restart Finder once again.
Now how would you remember these commands, the next time you want to see hidden files? There’s a workaround for that too.
We’ll create a file called .bash_profile in the home folder of Mac. .bash_profile contains your preferences, aliases etc.
- Open Terminal and type
open -e .bash_profile
- Once the file is open in Textedit, copy and paste this snippet into the file.
#reveal hidden folders in finder alias revealfol='defaults write com.apple.finder AppleShowAllFiles -bool true killall Finder' #hide folders in finder alias hidefol='defaults write com.apple.finder AppleShowAllFiles -bool false killall Finder'
- Save the file and quit the app.
- In terminal, type
- And you’re done.
What we have done a while ago is, create aliases for commands used for hiding and revealing folders. The aliases are
So, now if you type
revealfol in Terminal, it will reveal hidden folders for you.
hidefol will of course hide the folders, like you expected.
Hide existing folders
Let’s say you want to create a hidden folder or want to hide a folder you already created – it’s pretty easy.
All you need to do is rename the folder or file, by putting a dot (.) before it.
This works because OS X hides all files/folders whose name starts with a dot. They’re called dotfiles.
To rename a existing folder in Mac, open Terminal and type
mv ~/Documents/secrets.txt ~/Documents/.secrets.txt
In the above command, the first argument should be the original path of file and second argument should the path of renamed file (same name with dot before it).
That’s all. If you’re a developer or someone who messes with this kind of stuff, you must have already knew this.
This tutorial was more intended for beginners. 🙂