Home » Tech Tips » Mac » How to Hide and View Hidden Files on Mac?

How to Hide and View Hidden Files on Mac?

In our earlier article, we have explained how to view hidden files in Windows PC and hide files from other users. Similar to Windows, system files are hidden by default in Apple macOS also. However, you may need to view the hidden files in many situations. In this article, we will explain how to easily show or hide files in Finder and Desktop using Terminal and other options.

Why You Need to View Hidden Files?

Viewing hidden files is very useful in many situations.

  • You want to look for plist files or any other folders in your “Library” folder. By default, this is “Library” folder is hidden on your Mac.
  • When using FTP, you may need to upload some hidden files to your server.
  • If you are doing web development with local Apache server setup, then you may need to modify server configuration using .htaccess file.
  • If you are an administrator and sharing your Mac with multiple users, you may want to view the files hidden by other users on your Mac. 

How to View Hidden Files on Mac?

Follow the below instructions to view the hidden files on your Mac:

  • Press Command + Space to open Spotlight Search.
  • Type “terminal” and open the Terminal app.
  • Copy and paste the below command and press the Enter key. 
defaults write com.apple.finder AppleShowAllFiles YES
  • Hold the Option key and right-click on Finder app on your dock and select “Relaunch” option.
  • Open Finder and you will see all the hidden files are visible now.
  • Mac will show the hidden files in a dimmed color to differentiate them from other files / folders.
View .htaccess File in Mac OS X
View Hidden Files in Mac

How to Hide Files on Mac?

There are multiple ways to hide the system and user generated files. We strongly recommend taking a system backup regularly if you are frequently changing the file parameters and permissions. If a file doesn’t appear in Finder even after you show hidden files, it was most likely deleted rather than hidden. Check the Trash first, then restore it from Time Machine if you use it. If neither works, you need the best data recovery software for Mac to scan and recover the deleted files.

1. Hide Hidden Files

If you want to hide the hidden files, run the following command in Terminal app.

defaults write com.apple.finder AppleShowAllFiles NO

Relaunch the Finder and all system and special files will be hidden.

Viewing or hiding system and other hidden files is easy on a Mac, as explained above. However, hiding your own files or folders (like my-file.txt) is not as straightforward. Unlike Windows, macOS does not provide a graphical option to hide user created files and folders. Instead, you need to use one of the below methods to hide files or folders created by you or any other user (you should have admin access to modify other user’s files).

2. Move Folder and Files to Library Folder

As mentioned, Library folder is a system folder and Mac will hide it from all users in Finder app. If you want to keep files hidden from other users, then simply create a new folder inside Library folder and store your files. All folders inside Library folder will also be hidden and not visible to users.

  • If you have made the hidden files visible as explained in the above (in option 1), launch Finder and press Shift + Command + L. Alternatively, navigate to “Go > Library” menu to open Library folder. Remember, this option will be available only when you have enabled viewing the hidden files.
  • If you are in the default mode that hides system files, then you will not see “Library” folder in Finder “Go” menu. In this case, press Option key and click on the “Go” menu to view the “Library” option. Click on it to open “Library” folder.
Library Folder in Mac
Library Folder in Mac
  • Now, click on the gear dropdown or three-dots icon on the toolbar and choose “New Folder” to create a new hidden folder. Rename the “New Folder” as you need.
  • Move your files inside the “New Folder”.
  • Go to Terminal app and hide all systems files as explained above.

3. Set Visibility Parameter for Files

The next option is to change the visibility parameter of a file or folder using Terminal. Launch Terminal app and type the below command to hide the file.

chflags hidden <File Path>

If you don’t know the file path in Mac, just type chflags hidden without pressing the Enter key. Now, open Finder app and drag and drop the file or folder to the Terminal next to the command line. When dragging, you should see a green + icon and you will see the file path added to the command after dropping the file. If you want to unhide the file, simply change the command to unhidden like below.

chflags unhidden <File Path>

4. Add Dot Prefix to File Name

You can notice, Mac will hide the files that starts with dot like .htaccess. This is a common behavior as the text after dot is considered as file extension. Therefore, if you want to hide a file on your Mac, add a dot in the front to make it invisible by default. Mac will consider the file has only an extension with no name and hide it. You can unhide and change the name whenever needed.

5. Hide with XCode

The last option is to hide or view the files using Apple Developer Tools.

  • Go to App Store and install XCode app.
  • Open Terminal and run the command to hide the file. As mentioned earlier, you can drag and drop the file to add the file path in Terminal.
setfile -a V <File Path>
  • When you want to view the file, change the capital V to small v and run the command again.
setfile -a v <File Path>

Remember, XCode app needs 10+ GB size on your Mac for installation. Therefore, we do not recommend to install the app only for the purpose of hiding files.

Set File Permission Instead of Hiding

The above explained methods will help you to easily hide or view hidden files on your Mac. However, if you have multiple users on single Mac, the best option is to setup file permission and restrict file access from other users.

  • Select the file and press Command + I shortcut keys. Alternatively, right-click on the file or folder and select “Get Info” menu.
  • This will open the properties of the selected item.
  • Look at the last option “Sharing & Permissions”. Ensure to select “Read & Write” option only for your account and select “No Access” to “everyone”.
Set File Permission in Mac
Set File Permission in Mac

In addition, you can also use any third-party file manager app and set a password for accessing your confidential files and folders.

Leave a Comment

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