Home  >  Article  >  How to show hidden files on Mac

How to show hidden files on Mac

王林
王林forward
2023-04-16 21:19:052795browse

How to View Hidden Files on Mac

If you prefer to work by clicking, you can use the Finder app to show hidden files on macOS. Here's how it's done.

  1. Under Locations, click on your hard drive folder, probably named Macintosh HD.
    How to show hidden files on Mac
  2. When you first open it you won't see much, so press Command Shift Period. You'll see a number of other files and folders that are slightly grayed out to mark them as hidden.
    How to show hidden files on Mac
  3. Press the same key combination and these files and folders will disappear again.

This same key combination will work no matter which folder you have open in Finder.

How to Access the macOS Library Folder

Now, let’s say you just need to access your Mac’s Libraryfolder~/Library. You don't need to browse through all of your computer's folders to get there.

  1. In the top menu of Finder, click Go. How to show hidden files on Mac
  2. Initially, you won't see the libraries listed at all. Hold down the Option key and a new Library option will appear. Click it and your Mac's ~/Library folder will open in a new Finder window.
    How to show hidden files on Mac

How to Show Hidden Files on Mac Using Terminal

If you prefer working in Terminal, you can enable Show hidden files here. Just type the following commands:

defaults write com.apple.finder AppleShowAllFiles truekillall Finder

Once these commands run, a few things will happen. The Finder application will exit and restart on its own. You may see your desktop icons disappear and then reappear. Afterwards, you will be able to view all hidden files in Finder, as well as any temporary files saved on your desktop.

When you want to hide them again, you repeat these commands, replacing the value true with false.

defaults write com.apple.finder AppleShowAllFiles falsekillall Finder

Again, Finder will exit and restart. Those hidden files will be hidden from view again.

How to Hide Files on Mac Using Terminal

You might think this is more useful than doing everything in the Finder. However, Terminal can be great if you have files and folders on your Mac that aren't hidden but you want them to be.

To do this, here's what you need to do.

  1. OpenFinder to the directory containing the file you want to hide.
  2. In Terminal, type chflags hidden, followed by a space, but do not press Enter.
  3. Drag the file or folder you want to hide from Finder to TerminalWindow.
  4. The file or folder name will appear at the end of the chflags command.
  5. Now press Enter.

This will hide your file or folder from view. You can show it again using the terminal command above to make sure.

Quickly and temporarily display hidden files in Terminal

If you don't need or want to change how the Finder displays hidden files, you can list them in Terminal. You can do this using the command ls, list as appropriate.

  • From Terminal, type ls -a
  • You will see all the files in the current directory, including hidden files and folders .

This is the -a flag that makes a difference here. It tells the list command to display all files. If you want to do this on a different folder, that's easy.

  • From the terminal, type ls -a ~/.config
  • Just replace ~/.config is the folder you want to view.

If you need to open this file or folder in the GUI, you can do so using the open command. Here is an example:

  • open .not_visible will launch a file named .not_visible, assuming there is an application associated with it.

The same method also works for opening hidden folders in Finder.

  • open ~/.configwill open the hidden folder .config in a Finder window.

Be careful with hidden files

Remember, these files and folders are hidden for a good reason. If you accidentally delete or move folders or files that macOS depends on, it can cause some major problems. You may find yourself having to restore the operating system and then the remaining files and applications in Time Machine.

Please note that this does not mean don't try to use hidden files and folders. Just use your best judgment, err on the side of caution, and double-check what you're doing before you commit.

The above is the detailed content of How to show hidden files on Mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete