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.
This same key combination will work no matter which folder you have open in Finder.
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.
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.
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.
chflags hidden
, followed by a space, but do not press Enter. chflags
command. This will hide your file or folder from view. You can show it again using the terminal command above to make sure.
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.
ls -a
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.
ls -a ~/.config
~/.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 ~/.config
will open the hidden folder .config in a Finder window.
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!