How to Clear Program Cache Files on Linux Safely

To clear program cache files on Linux, inspect your user cache directory and remove only the cache folders you recognize. On many desktop systems, that directory is ~/.cache. Close the program first, check which folder is using space, and send the selected cache folder to Trash so you can review it before permanent deletion.

Find the Linux cache directory and check its size

The XDG Base Directory Specification sets $XDG_CACHE_HOME as the base for per-user, non-essential cached data. When that variable is unset or empty, its default is $HOME/.cache. Some applications use other locations or manage their caches inside the app, so check the path before removing files.

For a quick size check, open Terminal and run:

cache_dir="\${XDG_CACHE_HOME:-$HOME/.cache}"
printf 'Cache directory: %s\n' "$cache_dir"
du -sh "$cache_dir"
du -h --max-depth=1 "$cache_dir" | sort -h

The first du line reports the total; the second lists the immediate subfolders, with larger entries near the bottom. The --max-depth option is supported by GNU du, which is standard on most desktop Linux distributions; see the GNU Coreutils documentation for du. These commands only inspect sizes; they do not delete anything. If your cache directory is elsewhere, use the printed path when you scan it.

Inspect cache folders with Disk Usage Analyzer

GNOME’s Disk Usage Analyzer (also called Baobab) can scan one folder and show how its contents use disk space. You can use the steps below even if your Linux desktop has a different file manager; menu labels may vary.

Open Disk Usage Analyzer’s actions menu and choose Scan Folder.
Disk Usage Analyzer with its Scan Folder command open. Menu placement varies slightly by desktop version.
  1. Quit the application whose cache you plan to clear. A running program may recreate files while you are deleting them.
  2. Open Disk Usage Analyzer from the application menu. Open its menu in the upper-right corner and choose Scan Folder…. GNOME documents this option for scanning an individual folder.
  3. A file chooser with the hidden .cache folder selected in the home directory.
    Choose the cache directory shown by your system; .cache is hidden in many file managers.
  4. In the folder chooser, select the cache directory. In the default setup, open your home folder and select .cache. If hidden files are not visible, press Ctrl+H in GNOME Files; on another desktop, use its “Show Hidden Files” command. Select your custom $XDG_CACHE_HOME location instead if you use one.
  5. Disk Usage Analyzer showing a .cache folder scan with a folder list and ring chart.
    Example scan layout. Folder names and displayed sizes differ from one Linux system to another.
  6. Wait for the scan to finish, then look at the folder list and chart. Expand the tree or sort by size to find which application-specific subfolder accounts for the space. Disk Usage Analyzer can report permission errors when a folder is not readable; scan your own home cache as your regular user instead of launching the tool with sudo.

Move selected cache files to Trash

Only remove a folder after confirming that it contains temporary cache data for the application you intend to clean. If you are unsure what an app-specific folder stores, check that application’s documentation or use its own cache-clearing setting.

A file manager context menu with one cache subfolder selected and Move to Trash highlighted.
Move only a cache folder you have identified; the exact menu depends on your file manager.
  1. In Disk Usage Analyzer, right-click the identified folder and choose Move to Trash. GNOME’s help describes this as the way to delete an unwanted folder from the analyzer.
  2. Alternatively, open your home folder in the file manager, show hidden files, open .cache, and move the chosen app cache folder to Trash. Do not select adjacent folders just because they are large.
  3. Open Trash and review its contents. Empty it only when you are ready to permanently delete those items; Trash may contain unrelated files, too. Otherwise, leave the items there until you have confirmed the application works as expected.

When the app starts again, it may rebuild thumbnails, indexes, or other cache files. That can make its first launch or the next load slower, and some cached downloads may need to be fetched again. The cache can grow back as the app runs.

What not to delete

  • Do not treat settings and personal data as cache. Avoid deleting ~/.config or ~/.local/share when your goal is only to clear temporary files; applications commonly use those locations for configuration and user data.
  • Do not use root privileges for your own cache. Removing files from your home directory with sudo is unnecessary and can leave files owned by the wrong account.
  • Do not confuse app caches with package-manager caches. A system package manager has its own cleanup commands and locations. Clearing ~/.cache will not necessarily reclaim that space.
  • Do not assume every large folder is disposable. A profile, offline library, or downloaded file may be useful data even if it sits near cache directories.

Common problems

If a removed folder returns immediately, the app may still be open or may have recreated its cache. Quit it and check again later. If the available disk space does not change after moving files to Trash, review and empty Trash after checking its contents. If ~/.cache is small, use Disk Usage Analyzer to scan other folders you own; the cache is only one possible source of disk usage.

For current interface details, see the official GNOME guide to scanning a folder, GNOME’s instructions for moving folders to Trash, and the GNOME Files hidden-files guide.

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.