Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

Ubuntu Media Files and Thumbnail Cache Management

Published

UbuntuLinux and Commands

Introduction

Ubuntu automatically creates thumbnail images (small previews) for photos, videos, and documents to make file browsing faster and more visual. While these thumbnails improve your experience by showing quick previews in file managers, they can accumulate over time and consume substantial disk space, especially if you work with many media files. This article shows you how to manage media files and thumbnail cache effectively in Ubuntu. You will learn where thumbnails are stored, how to clean them safely, configure thumbnail settings, and implement strategies to keep media-related storage under control without losing the convenience of visual file previews.

Prerequisites

Before following this article, ensure you have:

  • An Ubuntu machine (any version)
  • Basic knowledge of using the terminal and file manager
  • Administrative privileges (ability to use sudo)
  • Understanding that thumbnails help with file browsing but can be recreated

Understanding Ubuntu’s Thumbnail System

Ubuntu’s thumbnail system creates small preview images to help you identify files quickly without opening them fully.

How Thumbnails Work

Ubuntu creates thumbnails for:

  • Image files (JPEG, PNG, GIF, etc.)
  • Video files (MP4, AVI, MKV, etc.)
  • PDF documents and some other document types
  • Some application files that contain preview-able content

These thumbnails are stored in hidden cache directories and are automatically created when you browse folders containing media files.

Where Thumbnails Are Stored

Ubuntu stores thumbnails in two main locations:

  • ~/.cache/thumbnails/ – Modern location used by current Ubuntu versions
  • ~/.thumbnails/ – Legacy location used by older Ubuntu versions and some applications

Both directories may exist on your system and can contain significant amounts of cached thumbnail data.

Check Your Current Thumbnail Usage

Before managing thumbnails, see how much space they’re currently using on your system.

Check Thumbnail Cache Size

Check the modern thumbnail location:

$ du -sh ~/.cache/thumbnails/

Check the legacy thumbnail location:

$ du -sh ~/.thumbnails/

Get total thumbnail usage:

$ du -sh ~/.cache/thumbnails/ ~/.thumbnails/ 2>/dev/null | awk '{sum+=$1} END {print "Total thumbnails: " sum}'

See what types of thumbnails you have:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -type f -name "*.png" | wc -l

This shows how many thumbnail files exist.

Analyze Thumbnail Directories

Look at thumbnail directory structure:

$ ls -la ~/.cache/thumbnails/ $ ls -la ~/.thumbnails/

You’ll typically see directories like normal, large, and fail containing different sizes of thumbnails.

Check which directories use the most space:

$ du -sh ~/.cache/thumbnails/*/ ~/.thumbnails/*/ 2>/dev/null | sort -hr

Clean Thumbnail Cache

Removing thumbnails is completely safe – Ubuntu will recreate them as needed when you browse media files.

Remove All Thumbnails

Clear modern thumbnail cache:

$ rm -rf ~/.cache/thumbnails/*

Clear legacy thumbnail cache:

$ rm -rf ~/.thumbnails/*

Clear both locations at once:

$ rm -rf ~/.cache/thumbnails/* ~/.thumbnails/* 2>/dev/null

Selective Thumbnail Cleanup

Remove only large thumbnails (keeps smaller ones for faster browsing):

$ rm -rf ~/.cache/thumbnails/large/* ~/.thumbnails/large/* 2>/dev/null

Remove thumbnails older than 30 days:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -type f -mtime +30 -delete 2>/dev/null

Remove failed thumbnail attempts (these don’t provide useful previews):

$ rm -rf ~/.cache/thumbnails/fail/* ~/.thumbnails/fail/* 2>/dev/null

Check Space Recovered

After cleanup, check how much space you freed:

$ du -sh ~/.cache/thumbnails/ ~/.thumbnails/ 2>/dev/null

Compare this to your initial measurements to see space recovered.

Configure Thumbnail Settings

Ubuntu allows you to control how thumbnails are created and managed through system settings.

Adjust Thumbnail Preferences

Open system settings and look for file manager preferences, or use the command line to configure thumbnail behavior.

Set maximum file size for thumbnail creation:

$ gsettings set org.gnome.desktop.thumbnailers maximum-size 10485760

This sets the limit to 10MB (adjust the number as needed).

Disable thumbnails for specific file types:

$ gsettings set org.gnome.desktop.thumbnailers disable-all false

Check current thumbnail settings:

$ gsettings list-recursively org.gnome.desktop.thumbnailers

Control Thumbnail Creation

Limit thumbnail creation to local files only (skip network locations):

$ gsettings set org.gnome.desktop.thumbnailers disable-remote true

Set thumbnail cache size limits by creating a cleanup routine rather than relying on automatic limits.

Manage Media File Organization

Better media file organization reduces thumbnail cache growth and improves system performance.

Organize Media Files Efficiently

Create a dedicated media directory structure:

$ mkdir -p ~/Media/{Photos,Videos,Documents,Archives}

Move scattered media files to organized locations:

$ find ~/Downloads -name "*.jpg" -o -name "*.png" -o -name "*.mp4" -exec mv {} ~/Media/Photos/ \;

Be careful with this command – test it first or move files manually.

Remove Duplicate Media Files

Find duplicate images (requires installing fdupes):

$ sudo apt install fdupes
$ fdupes -r ~/Media/Photos/

Remove duplicate files interactively:

$ fdupes -r -d ~/Media/Photos/

This will ask you which duplicates to keep.

Clean Up Media Downloads

Find old media files in Downloads:

$ find ~/Downloads -name "*.jpg" -o -name "*.png" -o -name "*.mp4" -o -name "*.pdf" -mtime +30

Remove old downloaded media files:

$ find ~/Downloads -name "*.jpg" -o -name "*.png" -o -name "*.mp4" -mtime +60 -delete

This removes media files older than 60 days from Downloads.

Set Up Thumbnail Maintenance Routines

Regular thumbnail maintenance prevents excessive cache growth while maintaining browsing performance.

Weekly Thumbnail Cleanup

Create a simple weekly routine:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -type f -mtime +14 -delete 2>/dev/null

Run this weekly to remove thumbnails older than 2 weeks.

Monthly Deep Cleaning

Perform monthly comprehensive thumbnail cleanup:

$ rm -rf ~/.cache/thumbnails/fail/* ~/.thumbnails/fail/* 2>/dev/null
$ find ~/.cache/thumbnails/ ~/.thumbnails/ -type f -mtime +30 -delete 2>/dev/null

Rebuild frequently used thumbnails by browsing your main media folders after cleanup.

Monitor Thumbnail Growth

Check thumbnail growth monthly:

$ echo "Thumbnail usage: $(du -sh ~/.cache/thumbnails/ ~/.thumbnails/ 2>/dev/null | awk '{sum+=$1} END {print sum}')" 

If thumbnail cache exceeds 500MB, perform cleanup or review media file organization.

Handle Large Media Collections

Systems with extensive media collections require special thumbnail management approaches.

Optimize for Large Photo Collections

Limit thumbnail creation to recently accessed files:

$ find ~/Pictures -type f -atime +90 -name "*.jpg" | head -20

This shows old photos that might have unnecessary thumbnails.

Consider moving archived photos to external storage to reduce thumbnail generation.

Manage Video File Thumbnails

Video thumbnails can be particularly large and numerous:

Check video thumbnail sizes:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -name "*video*" -exec du -sh {} \; 2>/dev/null

Remove video thumbnails specifically:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -name "*video*" -delete 2>/dev/null

Handle Document Thumbnails

PDF and document thumbnails also consume space:

Find document thumbnails:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -name "*pdf*" -o -name "*doc*" 2>/dev/null

Clean document thumbnails older than 60 days:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -name "*pdf*" -mtime +60 -delete 2>/dev/null

Alternative Media Management Solutions

Consider these approaches for better media management and reduced thumbnail overhead.

Use Dedicated Media Organizers

Install and use dedicated photo management tools:

$ sudo apt install shotwell

Shotwell manages its own thumbnails more efficiently than file manager previews. Consider using cloud storage for media files to reduce local thumbnail generation.

Implement Smart Storage Strategies

Keep frequently accessed media in fast locations, archive old media to external drives, and use symbolic links for organized access without duplicate thumbnails. Regular cleanup of Downloads and temporary media folders.

Troubleshoot Thumbnail Issues

Sometimes thumbnail systems can malfunction or cause problems that require specific fixes.

Fix Broken Thumbnail Generation

Reset thumbnail settings:

$ gsettings reset-recursively org.gnome.desktop.thumbnailers

Clear all thumbnail data and let it rebuild:

$ rm -rf ~/.cache/thumbnails/* ~/.thumbnails/*
$ nautilus ~/Pictures

This clears thumbnails and triggers regeneration when you browse photos.

Resolve Thumbnail Corruption

If thumbnails show incorrectly, remove and regenerate them:

$ find ~/.cache/thumbnails/ ~/.thumbnails/ -name "*.png" -size 0 -delete 2>/dev/null

This removes empty/corrupted thumbnail files.

Restart the file manager to refresh thumbnail generation:

$ killall nautilus
$ nautilus &

Handle Permission Issues

Fix thumbnail directory permissions:

$ chmod -R 755 ~/.cache/thumbnails/ ~/.thumbnails/ 2>/dev/null

This ensures proper access to thumbnail directories.

Monitor and Maintain Media Storage

Keep track of your media file and thumbnail usage to maintain optimal system performance.

Regular Storage Checks

Monthly media storage review:

$ echo "Photos: $(du -sh ~/Pictures | cut -f1)"
$ echo "Videos: $(du -sh ~/Videos | cut -f1)"
$ echo "Downloads: $(du -sh ~/Downloads | cut -f1)"
$ echo "Thumbnails: $(du -sh ~/.cache/thumbnails/ ~/.thumbnails/ 2>/dev/null | awk '{sum+=$1} END {print sum}')" 

Set alerts for excessive growth (manually check when thumbnails exceed 1GB).

Best Practices Summary

  • Clean thumbnails monthly or when they exceed 500MB
  • Organize media files in dedicated directories
  • Remove old downloads and duplicates regularly
  • Use appropriate thumbnail size limits
  • Consider external storage for archived media
  • Monitor growth trends to prevent storage issues

Conclusion

Managing media files and thumbnail cache in Ubuntu helps maintain system performance while preserving the convenience of visual file browsing. You learned to identify thumbnail storage locations, clean cache safely, configure thumbnail settings, and implement maintenance routines. Regular thumbnail maintenance prevents excessive disk usage without losing the benefits of quick file previews. The key is finding the right balance between cleanup frequency and thumbnail convenience based on your media usage patterns. Start by checking your current thumbnail usage and implementing basic cleanup routines. This simple maintenance will keep your Ubuntu system running efficiently while maintaining the visual file browsing experience that makes working with media files more productive.

Related guides

Account services are unavailable until the production backend is configured.