Cleanup unused files to free disk space in Linux

less than 1 minute read

Related: Find largest directory on Linux, Mac, Windows and BSD


Keep at least 10% of drive space to avoid:

  • SSD wear
  • HDD fragmentation

Determine free space

ncdu

uses Ncurses terminal “graphics” to quickly show the biggest files in the Linux filesystem tree. ncdu is very handy to find large files or directories under the ~ you may not need anymore.

df -h

gives a drive-level summary of disk usage.

Clear unused files

There are a few categories of files that are cached on a Linux system.

Clear package cache

On embedded systems like the Raspberry Pi and Beaglebone where eMMC or an SD card is used, it’s easy to use all available space. The package installation system cached installed files in case of need to reinstall, but this is a rare need.

apt autoclean

or

yum clean all

clears the package cache.

Free up LaTeX doc space

One of the largest directories on my PC was for TeXlive documentation.

Using Synaptic, I highlighted everything using search term texlive-doc. This also removes texlive-full but with no detriment to texlive working.

Synaptic list of files to remove for texlive-doc to save disk space
Packages removed for texlive-doc to save over 1 GB of disk space.

Categories:

Updated:

Leave a comment