ubuntu删除snap和log文件解决var区空间不足的问题

前言

最近突然系统跳出var区空间不足的提示,这往往是因为装双系统的时候分配的空间不够。

通过查询可以发现,一般是snap文件和log文件的原因,而这些文件大多无用却占用很大空间,因此可考虑删除。

删除snap文件

第1步: 进入文件所在位置

root@master:/var/lib/snapd/snaps# ls
	bare_5.snap                                          gnome-characters_761.snap
	core18_2344.snap                                     gnome-logs_106.snap
	core18_2409.snap                                     gnome-logs_112.snap
	core20_1494.snap                                     gnome-system-monitor_148.snap
	core20_1518.snap                                     gnome-system-monitor_174.snap
	gnome-3-34-1804_72.snap                              gtk-common-themes_1534.snap
	gnome-3-34-1804_77.snap                              gtk-common-themes_1535.snap
	gnome-3-38-2004_106.snap                             partial
	gnome-3-38-2004_112.snap.xdelta3-106-to-112.partial  pycharm-community_281.snap
	gnome-3-38-2004_99.snap                              pycharm-community_286.snap
	gnome-calculator_884.snap                            snapd_15904.snap
	gnome-calculator_920.snap                            snapd_16010.snap
	gnome-characters_741.snap

第2步:查看文件版本的可用性

root@master:/var/lib/snapd/snaps# snap list --all
	Name                  Version                Rev    Tracking         Publisher   Notes
	bare                  1.0                    5      latest/stable    canonical✓  base
	core18                20220309               2344   latest/stable    canonical✓  base,disabled
	core18                20220428               2409   latest/stable    canonical✓  base
	core20                20220512               1494   latest/stable    canonical✓  base,disabled
	core20                20220527               1518   latest/stable    canonical✓  base
	gnome-3-34-1804       0+git.3556cb3          72     latest/stable/…  canonical✓  disabled
	gnome-3-34-1804       0+git.3556cb3          77     latest/stable/…  canonical✓  -
	gnome-3-38-2004       0+git.09fbd6c          106    latest/stable    canonical✓  -
	gnome-3-38-2004       0+git.1f9014a          99     latest/stable    canonical✓  disabled
	gnome-calculator      41.1-4-g5c9869a58c     920    latest/stable/…  canonical✓  -
	gnome-calculator      3.38.2+git3.1d166209   884    latest/stable/…  canonical✓  disabled
	gnome-characters      41.0-6-g3387c148db     761    latest/stable/…  canonical✓  disabled
	gnome-characters      41.0+git1.8877a99      741    latest/stable/…  canonical✓  -
	gnome-logs            3.36.0                 112    latest/stable/…  canonical✓  -
	gnome-logs            3.36.0                 106    latest/stable/…  canonical✓  disabled
	gnome-system-monitor  3.36.0-12-g35f88a56d7  148    latest/stable/…  canonical✓  disabled
	gnome-system-monitor  41.0-5-g91e67f7982     174    latest/stable/…  canonical✓  -
	gtk-common-themes     0.1-79-ga83e90c        1534   latest/stable/…  canonical✓  disabled
	gtk-common-themes     0.1-81-g442e511        1535   latest/stable/…  canonical✓  -
	pycharm-community     2022.1.2               281    latest/stable    jetbrains✓  disabled,classic
	pycharm-community     2022.1.3               286    latest/stable    jetbrains✓  classic
	snapd                 2.56                   16010  latest/stable    canonical✓  snapd
	snapd                 2.55.5                 15904  latest/stable    canonical✓  snapd,disabled

可见很多disable的版本,即可删掉
第3步:直接删除相应文件(像很多使用snap remove指令的教程并不管用)

root@master:/var/lib/snapd/snaps# rm -f gnome-3-38-2004_99.snap

删除log文件

直接进入对应目录,删除相应文件

root@master:/var/log/journal# ls
	ff4576929c54499eab292509671345ed
root@master:/var/log/journal# rm -r ff4576929c54499eab292509671345ed/

你可能感兴趣的:(ubuntu,ubuntu,linux,服务器)