萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 電腦基礎知識 >  >> 電腦基本常識

macOS 顯示/隱藏隱藏檔案終端機指令:defaults write 開關 AppleShowAllFiles

macOS 預設隱藏以點 (.) 開頭的檔案/資料夾(如 `.git`、`.ssh`、`.DS_Store`、`.bash_profile`)。終端機指令一鍵切換顯示狀態:

顯示隱藏檔案

defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder

隱藏隱藏檔案(恢復預設)

defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder

指令解析

  • defaults write:寫入使用者偏好設定資料庫
  • com.apple.finder:Finder 偏好設定域
  • AppleShowAllFiles:控制隱藏檔案顯示的鍵值
  • -bool true/false:布林值開關
  • killall Finder:重啟 Finder 使設定即時生效(或重新登入/重開機)

替代方案(無需終端機)

  • 鍵盤快捷鍵 (macOS Sierra 10.12+): 在 Finder 中按 Command (⌘) + Shift (⇧) + . (句點) 切換顯示/隱藏
  • 第三方工具: Funter (免費選單列開關)、TotalFinder (付費功能增強)
  • Automator 快速動作/服務: 封裝上述指令為右鍵選單/選單列服務

適用場景

  • 開發者:查看/編輯 `.gitignore`、`.env`、`.vimrc`、`.zshrc` 等設定檔
  • 系統管理:檢查 `.DS_Store`、`.localized`、`.Spotlight-V100` 等系統檔
  • 資料救援:尋找隱藏資料夾中的遺失檔案
  • 清理:發現並刪除佔用空間的隱藏暫存檔/快取

注意

  • 系統關鍵隱藏檔案(如 `.Spotlight-V100`、`.fseventsd`、`.Trashes`)請勿隨意刪除/移動
  • 顯示隱藏檔案會增加視覺雜訊,用畢建議關閉
  • 指令需區分大小寫,`-bool true/false` 有空格

掌握指令與快捷鍵雙管道,按需切換隱藏檔案可見性,兼顧效率與介面乾淨。

copyright © 萬盛學電腦網 all rights reserved