sudo journalctl --vacuum-size=300Mreduces the logs to 300 MBsudo logrotate /etc/logrotate.confcompresses or (?) deletes system logssudo apt-get autoremoveremoves software that are only dependencies to packages you removed earlier and don't need anymoresudo apt-get cleanthis is nearly the same assudo rm -rf /var/cache/apt/archives/*and deletes cached downloaded packages for installation. Running this during some installations could be a problem.- Deleting files from the trashbin
trash:/and checking if there's any large files that could be deleted in /tmp:find /tmp -type f -size +50M -exec du -h {} \; | sort -n - Identifying largest files with a command like
sudo find / -mount -type f -size +100M -exec du -h {} \; | sort -n(a few more are here and here) or with a GUI likegdmap(Graphical Disk Map) and then either moving/deleting them or creating symbolic links.- For example, to create a symbolic link for the relatively large daily.cld file of ClamTk one could run
sudo mv /var/lib/clamav/daily.cld /home/username/Software/daily.cldthensudo ln -s "/home/username/Software/daily.cld" "/var/lib/clamav/daily.cld"so this also works for files used by software that expect the file to be in a specific location. Directories where one can commonly find large files include/opt/.
- For example, to create a symbolic link for the relatively large daily.cld file of ClamTk one could run
- Another thing one can do is deduplicating things media by replacing duplicates with symlinks but I don't know of a command or tool that does that (or helps you do that)
- The GUI
BleachBitmay have some additional ways
If, like me, you had your system crash or not be able to run the desktop environment (such as KDE Plasma) because of too little disk space, you could run the CLI commands from a TTY to delete files from there to free up enough disk space. You can switch to a virtual terminal (TTY) and back with Ctrl+Alt+F1 (or F2,F3,..). Once you have freed up enough disk space you can switch back using these shortcuts and restart the desktop environment (for KDE that's kstart5 plasmashell).
If you have this problem because you need more disk space for a distro upgrade, I suggested a stepwise upgrade as a solution that would make this redundant and avoid upgrade interruptions due to No disk space left. There devs brought up some alternatives:
- Running the command with the cache directory elsewhere, for example:
apt upgrade -o dir::cache::archives=/media/apt-archives - untested:
while sudo apt -s upgrade | grep '^Inst' | head -1 | awk '{print $2}' | xargs apt install; do sudo apt clean; done("Use head -10 or whatever fits for more/less packages")