【Mac】 磁盘占满清理查找无用文件

本文介绍了如何使用du命令查找并清理Mac系统中占用大量磁盘空间的文件和目录,包括递归查看文件大小、关闭System Integrity Protection进行深度搜索,以及谨慎删除不必要的缓存文件。同时提醒用户在清理时要注意不要误删重要文件。
摘要由CSDN通过智能技术生成

目录

一. 问题

二. 解决

2.1 du 命令

2.2 System Intergrity Protecton

2.3 查找

三. 参考


一. 问题

        最近更新系统后,次哦,系统数据 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 模式,步骤如下:

  1. 重启 mac 电脑,然后 Command + R 键不动;
  2. 进入 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 下子目录,具体删除哪个,看个人平常需要了;

三. 参考

  1. 【Windows】【Mac】powershell 和 bash 别名_DovSnier 专栏-CSDN博客
  2. 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值