Hide and View Hidden Files on Mac OS X - A Guide

Hiding Files and Folders on macOS
Similar to other operating systems, macOS provides functionality for concealing files and folders from typical user views.
However, the mechanisms for achieving this are less immediately apparent on Mac OS X compared to systems like Windows or Linux.
Setting the Hidden Attribute
The core method for hiding files or folders on a Mac involves modifying their "hidden" attribute.
When this attribute is set, the Finder and most other applications will cease to display the item by default.
Essentially, the file or folder remains on the system, but it's rendered invisible during normal browsing.
This provides a degree of organization and can be useful for concealing system files or sensitive data.
It's important to note that this isn't a security measure; a user can easily reveal hidden files with the appropriate commands.
Concealing Files or Folders on a macOS System
Related: Methods for Hiding Files and Folders Across Different Operating Systems
Instead of concealing a single file – though that is certainly possible – you might prefer to establish a hidden folder. This demonstration will focus on creating a hidden folder, but the same technique applies to individual files as well.
Begin by launching a terminal window. This can be achieved by pressing Command+Space, typing "Terminal," and then pressing Enter.
Using the 'chflags' Command
Within the terminal, input the following command, ensuring a space is included at the end:
chflags hidden
Subsequently, locate the folder or file you wish to hide within the Finder.
Drag and drop this item directly into the open terminal window.
The complete file path will then be displayed in the terminal. Press Enter to execute the command.
Upon execution, the file or folder will become invisible. It remains on your system, but is hidden from standard Finder view.
To reiterate, the file or folder hasn’t been deleted; it’s simply concealed and won’t be displayed by the Finder in its default settings.
Gaining Access to Concealed Files or Directories
Do you need swift access to a hidden directory within Finder? A straightforward method involves clicking the "Go" menu in Finder and then choosing "Go to Folder."
Within the resulting dialog box, input the directory's path and then click "Go" or press the Enter key. The tilde symbol (~) represents your user directory.
Using the "Go to Folder" Feature
For example, if you have a folder named "SecretStuff" located on your desktop, you would enter "~/Desktop/SecretStuff." If the folder resides within your Documents directory, the path would be "~/Documents/SecretStuff."
Even though the folder is hidden and doesn't show up in standard Finder views or save dialogs, this method provides quick access. Files stored within this directory are effectively concealed.
Accidental discovery of the folder is prevented, but it will become visible in Finder if accessed directly through this method. This offers a simple layer of protection for sensitive data.
Important Note: This method hides files from casual browsing, but doesn't provide robust security. Anyone with access to your account can still find these folders.
Accessing Concealed Files and Folders via Open/Dialog
Although the Finder application lacks a direct visual setting for locating hidden files and folders, the Open and Save dialog within macOS provides this functionality.
To reveal hidden items in the Open/Save dialog, simply utilize the keyboard shortcut Command+Shift+Period (the . key).
Following the shortcut, a click on a different folder within the dialog is necessary for the change to take effect. For instance, if the concealed folder resides on the desktop, it won't be immediately visible after pressing Command+Shift+Period. Navigate to another folder first, then re-select the Desktop folder to display the hidden files and folders for convenient access.

Displaying Concealed Files within Finder
The Finder application on macOS includes a method for revealing files that are normally hidden from view. However, this functionality isn't accessible through a standard graphical interface.
Instead, enabling the display of hidden files requires utilizing the Terminal application and executing specific commands, followed by a Finder restart to implement the changes.
Activating Hidden File Visibility
To make hidden files visible in Finder, launch the Terminal application and sequentially enter the following commands, confirming each with the Enter key:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
This sequence instructs Finder to display all files, including those designated as hidden, and subsequently restarts the application to apply the new setting.
Once completed, previously concealed files and folders will become visible, appearing with a semi-transparent quality to differentiate them from standard, non-hidden items.
Reverting to Default Hidden File Settings
To disable the display of hidden files and folders, and return to the default Finder behavior, execute the following commands within the Terminal:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
This will revert the setting and restart Finder, effectively concealing the previously visible hidden files and folders once more.
For users desiring a more convenient method, an Automator script can be created. This script would automate the execution of these commands upon a designated key press or menu selection, providing quick toggling of hidden file visibility.
Revealing Hidden Files and Folders
To make a concealed file or folder visible again, execute the same command previously used, but substitute "hidden" with "nohidden." Specifically, enter the following command into the terminal, ensuring a space follows it:
chflags nohidden
If the precise file or folder path is known, it can be directly typed into the terminal. Alternatively, the method described earlier can be employed to reveal hidden files and folders within Finder.
These revealed items can then be dragged and dropped into the Terminal, mirroring the previous process.

The terminal also allows for command history recall. Pressing the up arrow key cycles through prior commands.
Locate the command that initially concealed the file or folder, navigate to the "hidden" portion using the left arrow key, and change it to "nohidden." Subsequently, press Enter.
Upon pressing Enter, the file or folder will be unhidden, restoring normal access.

Another method for concealing files or folders involves renaming them to begin with a period (".") character. However, macOS prevents renaming files this way directly from the Finder interface.
Therefore, this action must be performed through the Terminal. Various Terminal commands are available to display these hidden items as well.
This technique can be useful in shared computer environments. However, it's important to note that determined users can readily discover these hidden files and folders. For robust file and folder protection, encryption is recommended.
Image Credit: Quentin Meulepas on Flickr