If you have limited storage space and don't check up regularly on your on your files your OS can quickly run out of storage. This will manifest as all kinds of errors and be a general headache. In this blog, we will let you know how to quickly diagnose and deal with the issue.
First, you can use the command df -h
to check if your storage is full. Your output will be similar to this:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 47G 1.5G 97% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 1.2M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 798M 12M 786M 2% /run/user/1000
As you can see, the root directory /
is almost full. To find out what files are taking up the most space you can use the command find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -n 20
This will list the top 20 biggest files on your system from biggest to smallest. The output will be similar to this:
15G /var/log/syslog.1
12G /home/user/backup/full_backup_20231001.tar.gz
8.5G /var/lib/mysql/ibdata1
3.2G /home/user/videos/movie.mp4
2.5G /opt/applications/docker/images/cache.tar
1.8G /usr/lib/libtensorflow.so
1.6G /var/log/syslog.2.gz
1.4G /home/user/virtual_machines/ubuntu.vdi
1.2G /home/user/downloads/ubuntu-22.04.iso
1.1G /usr/local/bin/jupyter_notebook_archive.tar.gz
900M /var/log/kern.log.1
850M /usr/lib/x86_64-linux-gnu/libcuda.so
720M /usr/share/icons/icons.tar.gz
690M /var/log/auth.log.1
600M /home/user/music/album.flac
580M /var/cache/apt/archives/google-chrome.deb
550M /usr/lib/firefox/libxul.so
530M /opt/intellij_idea/ideaIU-2023.2.tar.gz
500M /home/user/.cache/thumbnails/thumb_cache.db
480M /var/tmp/core_dump_20230930.dmp
When you have decided what file you want to remove use the rm [file path]
command to delete it. In this example, if we want to delete the file syslog.1
we will run the command rm /var/log/syslog.1
.