How to Clear the Ubuntu ‘Thumbnail Cache’ (Fix Broken Image Previews)

When you open the default file manager in Ubuntu Linux (Nautilus) and navigate to a folder filled with images or videos, the system automatically generates tiny preview images for every single file. To prevent your computer from having to regenerate these previews every time you open that folder, Ubuntu stores all of these tiny images in a hidden “Thumbnail Cache” directory in your home folder.

If you are a photographer or video editor dealing with thousands of media files, this hidden cache can quietly balloon to several gigabytes in size, wasting valuable SSD space. More annoyingly, the cache can become corrupted, resulting in broken image icons, black squares, or Nautilus crashing entirely when trying to load a specific folder. The easiest fix is to simply delete the entire cache.

How to Clear the Ubuntu Thumbnail Cache via Terminal

Because the cache is located in a hidden .cache directory, deleting it via the terminal is the fastest and safest method.

  1. Open your Terminal application (Ctrl + Alt + T).
  2. To see exactly how much disk space your thumbnail cache is currently wasting, run the following command: du -sh ~/.cache/thumbnails
  3. The terminal will output a size (e.g., 1.2G or 450M). If you want to delete this data and fix your broken previews, proceed to the next step.
  4. Carefully copy and paste the following command to aggressively delete the thumbnails folder and all its contents: rm -rf ~/.cache/thumbnails/*
  5. Press Enter. The command will execute silently without any confirmation prompt.

The cache is now completely empty. The next time you open a folder containing photos or videos, Nautilus will simply generate fresh, uncorrupted thumbnails for those files on the fly, instantly fixing any black squares or broken icons you were previously experiencing.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.