How to Hide and View Hidden Files in Mac?
In our earlier article, we have explained how to view hidden files in Windows and hide files from other users. Similar to Windows, system files are by default hidden in Apple macOS. However, you can use the Terminal (Command Prompt in Mac) app to show or hide the hidden files in Finder.
Why You May 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. This is Library folder is by default 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 files like .htaccess file.
- When you share the Mac with multiple users, you may want to view the files hidden by other users on your Mac.
How to View Hidden Files in 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 hit enter key.
defaults write com.apple.finder AppleShowAllFiles YES
- Press option key and right-click on the Finder app on your dock and select “Relaunch” option.
- Now, open Finder and you will see all hidden files on your Mac.
- Mac will show the hidden files in a dimmed color.
- If you want to hide the hidden files, run the following command in Terminal app.
defaults write com.apple.finder AppleShowAllFiles NO
How to Hide Files in Mac?
Viewing and hiding the system or default hidden files is easier in Mac as explained above. However, it is a tricky task to hide a users file or folder in Mac. Unlike Windows, you don’t have any graphical interface to hide user files or folders in Mac. There are different methods to hide files / folders created by users.
1. Move Folder and Files to Library Folder
As mentioned, Library folder is a system folder and Mac by default will hide from all users in the 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 section, 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 to view 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.
- Now, click on the Gear dropdown 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.
2. Set Visibility Parameter of File
The second 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 enter key. Now open Finder app and drag and drop the file or folder to the Terminal next to the command. 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>
3. Add Dot in 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 then add a dot in the front to make it invisible by default. You can unhide and change the name whenever needed.
4. 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 6+ 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, use this to only view or hide default system files and do not use these methods to view or hide confidential files. You can use file manager with password option to setup strong password for your confidential files and folders. In addition, you can also setup file permission to restrict access only to you.
- 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”.