目录
2.2 System Intergrity Protecton
一. 问题
最近更新系统后,次哦,系统数据 132G ???
我平常都没下载啥东西啊,我要找找占用磁盘空间都是啥玩意占用了。
二. 解决
2.1 du 命令
使用如下命令:
## 磁盘目录文件占用空间分布
# 1. 查看递归目录占用空间
$ du -sh *
# 2. 只查看一级目录占用空间
$ du -d 1 -h
# 3. 排序
# 推荐
$ du -sh *|sort -hr
# 不推荐
$ du -sh *|sort -nr
# 4. 递归排序
$ du -ah .|sort -hr
2.2 System Intergrity Protecton
如果再查找过程中遇到如下问题?
du: ./Library/XXX/com.apple.XXX: Operation not permitted
然后关闭 SIP 模式,步骤如下:
- 重启 mac 电脑,然后 Command + R 键不动;
- 进入 Recovery 模式,打开终端(Terminal) ,参考如下命令:
# 1. 查询 SIP 状态
$ csrutil status
# 2. 关闭 SIP
$ csrutil disable
# 3. 重启
$ reboot
#
# 4. 一系列操作完后...
#
# 5. 强烈建议,开启 SIP(System Integrity Protection), rootless 机制
$ csrutil enable
2.3 查找
使用 du 命令查找占用空间最大的目录,如下:
$ du -sh *
2.7M Accounts
3.1G Android
184K Application Scripts
4.3G Application Support
988K Assistant
0B Assistants
8.0K Audio
136K Autosave Information
37M Biome
252K CBox
9.6G Caches
10M Calendars
0B CallServices
0B ColorPickers
0B ColorSync
0B Colors
0B Compositions
4.0K Contacts
8.0K ContainerManager
39G Containers
184K Cookies
28K CoreFollowUp
12K DataDeliveryServices
4.9G Developer
296K Dictionaries
44K DoNotDisturb
0B DuetExpertCenter
92K Edraw
0B Family
0B Favorites
24K FileProvider
32K FontCollections
0B Fonts
80K FrontBoard
0B GameKit
9.8M Google
141M Group Containers
2.0M HTTPStorages
7.5M HomeKit
2.5M IdentityServices
0B Input Methods
3.9M Internet Plug-Ins
25M Jupyter
136K Keyboard
0B Keyboard Layouts
1.0M KeyboardServices
27M Keychains
268K LanguageModeling
36K LaunchAgents
334M Logs
0B Maps
...
136K Personas
4.7M Photos
0B PhotoshopCrashes
0B PreferencePanes
...
1.6M Printers
208K PubSub
0B Python
...
0B VoiceTrigger
0B Voices
3.3M Weather
3.0M WebKit
16K com.apple.appleaccountd
8.0K iMovie
12K iTunes
736K sapi
20K studentd
切勿全删!!!
然后比葫芦画瓢,删除平常不用的 Cache 下子目录,具体删除哪个,看个人平常需要了;
三. 参考
- 【Windows】【Mac】powershell 和 bash 别名_DovSnier 专栏-CSDN博客
- https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html#:~:text=To%20%EE%80%80enable%EE%80%81%20or%20disable%20System%20Integrity%20Protection%2C%20you,menu.%20Enter%20the%20following%20command%3A%20%24%20%EE%80%80csrutil%20enable%EE%80%81.