Practical macOS Tips

January 9, 2025

Showing and deleting hidden files (dotfiles) on macOS

If files whose names begin with a dot (.) don't appear in the Trash, macOS is treating them as hidden files. You can list them in Terminal or turn on hidden files in Finder to see them in the Trash.

Method 1: Toggle hidden files with a keyboard shortcut

Open Finder. On the desktop or inside a folder, press:

Shift + Command + .(句点)

This toggles all files and folders whose names begin with a dot (.), including hidden files in the Trash.

  1. Open Terminal under Applications > Utilities.

  2. Enter this command to list all files in the Trash, including hidden ones:

ls -a ~/.Trash/
  1. To delete a particular hidden file, such as .myHiddenFile.txt, enter:
rm ~/.Trash/.myHiddenFile.txt

Remember to include the leading ..

  1. If the file is in a subfolder, such as ~/.Trash/.config/myHiddenFile.txt, enter:
rm ~/.Trash/.config/myHiddenFile.txt

Warning: rm permanently deletes files without sending them to the Trash. Use it with care.

Method 3: Restore a file to its original location in Finder

If you just want to recover a file:

  1. Press Shift + Command + . to show hidden files.
  2. Find the file.
  3. Right-click it and choose “Put Back.”

The file will return to its original location.

Tips

  • Many system and configuration files, including .DS_Store, .bash_profile, and .zshrc, begin with a dot and are hidden by default.
  • When emptying the Trash, hold down Option as you click Empty to delete the files permanently and skip the confirmation dialog.

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-01-09). Practical macOS Tips. https://caiborui.com/blog/2025-01-09-zh-macos-tips-entrans

@misc{borui2025-5d93327f,
  author = {borui},
  title = {{Practical macOS Tips}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-01-09-zh-macos-tips-entrans}
}