I need to free up disk space on my linux server. I run the df command to check space ad see that I'm using up 100% of disk space.
myserver:/ # df /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 22775924 21448960 146960 100% /
I then run du -h --max-depth=1 and I see that root and var take up most space:
sudo du -h --max-depth=1
362M ./run
2.8G ./opt
16K ./lost+found
0 ./sys
4.0K ./selinux
1.6M ./bin
542M ./home
56M ./boot
40M ./etc
2.3G ./var <---- 2.3 G
40K ./tmp
8.8M ./lib64
845M ./lib
4.0K ./mnt
0 ./dev
0 ./proc
7.4M ./sbin
2.2G ./snap
20K ./srv
2.5G ./root <--- 2.5 G
12G ./usr
24G .
I cd into root and check its contents as follows:
cd /root/
myserver:~ # sudo du -h --max-depth=1
70M ./Downloads
4.0K ./Public
8.0K ./.keras
4.0K ./Music
4.0K ./bin
1.2M ./Pictures
2.4G ./.cache <-- 2.4G
8.0K ./.nv
9.1M ./Videos
12K ./.dbus
12K ./.gnupg
64K ./.java
38M ./.mozilla
4.0K ./Desktop
8.0K ./.vnc
52K ./.subversion
4.0K ./Documents
596K ./.config
4.0K ./Templates
20K ./snap
1020K ./.local
2.5G .
And see that .cache is very large at 2.4G so I cd in here and check its contents:
cd .cache/
myserver:~/.cache # ls -l
total 208
drwxr-xr-x 3 root root 4096 Aug 7 10:10 JetBrains
drwxr-xr-x 3 root root 4096 Sep 25 10:06 TeamViewer
drwx------ 2 root root 4096 Aug 11 06:57 dconf
drwxr-xr-x 2 root root 4096 Aug 11 05:23 gstreamer-1.0
drwx------ 2 root root 4096 Aug 6 15:49 libgweather
drwxr-xr-x 3 root root 4096 Aug 6 11:58 matplotlib
drwx------ 3 root root 4096 Aug 6 15:49 mozilla
drwx------ 5 root root 4096 Aug 3 06:21 pip
-rw-r--r-- 1 root root 165196 Aug 6 16:00 qt_compose_cache_little_endian_89282f2dafab46408a426c3d8ad33da7
drwxr-xr-x 2 root root 4096 Sep 25 10:07 qtshadercache
drwx------ 4 root root 4096 Sep 1 06:20 thumbnails
drwxr-xr-x 3 root root 4096 Aug 6 12:17 torch
Is it safe to delete the whole contents of this .cache folder without messing up anything?
Are these .cache contents used for anything after the packages have been installed??
Are there any 'better' ways to free up space?
/root/.cache
on your instance holds/may hold. Look inside, see if you can make sense of the files present and their timestamps ... even try to find the culprit.cd /root/.cache; du -sm *|sort -n
...