{"id":16834,"date":"2025-06-13T08:34:00","date_gmt":"2025-06-13T07:34:00","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=16834"},"modified":"2025-06-13T08:34:00","modified_gmt":"2025-06-13T07:34:00","slug":"how-to-clear-cache-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/","title":{"rendered":"How to Clear Cache in Ubuntu? Detailed Easy Steps"},"content":{"rendered":"\n<p>Just like any other operating system, Ubuntu saves cache to increase speed and improve responsiveness. However, over time, the accumulated cache can lead to sluggish performance and waste valuable disk space. If you are experiencing storage problems or fixing network issues, clearing out the cache could be helpful.<\/p>\n\n\n\n<p>In this article, we discuss different types of cache in Ubuntu and their effective methods of removal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Clear Cache in Ubuntu?<\/h2>\n\n\n\n<p>Here are some forms of cache with their respective removal techniques.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Clear APT Cache<\/h3>\n\n\n\n<p>APT cache keeps package files in \/var\/cache\/apt\/archives\/.<\/p>\n\n\n\n<p>To clear all cached package files, follow the below command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo apt clean<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>To clear only outdated packages, run the below command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo apt autoclean<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>This allows for some space to be freed without any harm done to the installed software.<\/p>\n\n\n\n<p><strong>Related Read:<\/strong> <a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-clear-the-local-dns-cache-in-linux\/\">Learn to clear the local DNS cache in Linux<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Clear Thumbnail Cache in Ubuntu<\/h3>\n\n\n\n<p>The thumbnail cache can take unnecessary space and is located in the user\u2019s home directory.<\/p>\n\n\n\n<p>To clear the thumbnail cache, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>rm -rf ~\/.cache\/thumbnails\/*<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>This command will safely delete all the preview images.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Clear Application\/User Cache<\/h3>\n\n\n\n<p>General application or user cache can be found in this directory: <strong><em>~\/.cache\/.&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p>To remove all of the general application or user cache, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>rm -rf ~\/.cache\/*<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>Tip: Make sure any running applications are closed before clearing to avoid problems.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Clearing DNS Cache in Ubuntu<\/h3>\n\n\n\n<p>When resolving network problems, you may want to clear the DNS cache in Ubuntu.<\/p>\n\n\n\n<p>For systemd-resolved (Ubuntu 18.04+):&nbsp;&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo systemd-resolve --flush-caches <\/em><\/strong>&nbsp;<\/code><\/pre>\n\n\n\n<p>You can verify whether your DNS cache in Ubuntu is cleared, with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>systemd-resolve --statistics&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>For<strong><em> dnsmasq or nscd<\/em><\/strong> (if installed):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo \/etc\/init.d\/dnsmasq restart&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo service nscd restart&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>This process is also known as Ubuntu <a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/flush-dns-cache-mac\/\">DNS flush<\/a> or Ubuntu reset DNS cache.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GUI Applications to Clear Cache in Ubuntu<\/h2>\n\n\n\n<p>Of course, there are GUI applications such as<\/p>\n\n\n\n<p>BleachBit: It\u2019s a privacy and system cleaner application. You can install BleachBit on your Ubuntu server with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo apt install bleachbit&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>This allows you to choose the various cache files to be deleted, such as the browser, system, and package manager caches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automating Cache Clearing in Ubuntu<\/h2>\n\n\n\n<p>To automate the process of cleaning the caches, you can create a cron job:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>crontab -e&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>Add the following line to remove APT and thumbnail cache every week:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>@weekly sudo apt clean &amp;&amp; rm -rf ~\/.cache\/thumbnails\/*&nbsp;&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>If run without a prompt, you will need to set sudo permissions for the command to run safely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Running Low on Disk Space?<\/h2>\n\n\n\n<p>In case you are still low on disk space after clearing your cache, you may want to consider the following:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Removing old kernels<\/h3>\n\n\n\n<p>To remove those, run the below command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo apt autoremove --purge<\/em><\/strong>&nbsp;&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Checking large files<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo du -sh \/* 2&gt;\/dev\/null<\/em><\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Using visualization tools like ncdu:&nbsp;&nbsp;<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo apt install ncdu<\/em><\/strong>\n\n<strong><em>ncdu \/<\/em><\/strong><\/code><\/pre>\n\n\n\n<div class=\"vlt-box \">\n<div class=\"box-title\" style=\"background:#D5EAFF; color:#000\">Conclusion<\/div>\n<div class=\"box-content\" >\n<p>Regular cache maintenance in Ubuntu, be it APT, DNS, thumbnail, or user caches, will not only enhance system responsiveness and alleviate frequent problems but also improve overall efficiency and productivity. Terminal commands or GUI tools, such as BleachBit, can be used to maintain system cleanliness and optimization.<\/p>\n<p>Similar Reads:<br>\n\u276f <a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-iphone\/\">How to Clear Cache in iPhone: Complete Step-by-Step Guide<\/a><br>\n\u276f <a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-npm\/\">Clear Cache NPM: Easy Guide for Beginners<\/a><\/p>\n<\/div><\/div>\n\n\n\n<div class=\"vlt-box \">\n<h2 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">Frequently Asked Questions (FAQs)<\/h2>\n<div class=\"box-content\" >\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">How can I clear the thumbnail cache in Ubuntu?<\/h3>\n<p>You can clear it using<br>\nrm -rf ~\/.cache\/thumbnails\/*<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">Are there any GUI tools to clear the cache in Ubuntu?<\/h3>\n<p>Yes. Tools like BleachBit let users clear their cache using a graphical interface.<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">My Ubuntu server\u2019s disk space is still low after clearing the cache. What else can I do?<\/h3>\n<p>Remove old kernels, clear unneeded applications, or visually assess your disk usage with ncdu.<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">How can I automate the process of clearing the cache in Ubuntu?<\/h3>\n<p>Set up a cron job running on a daily or weekly basis that executes cache-clear commands. Furthermore, regular cache maintenance makes for a responsive Ubuntu system while minimizing the chances of sudden slowdowns.<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Just like any other operating system, Ubuntu saves cache to increase speed and improve responsiveness. However, over time, the accumulated cache can lead to sluggish performance and waste valuable disk space. If you are experiencing storage problems or fixing network issues, clearing out the cache could be helpful. In this article, we discuss different types [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-16834","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Clear Cache in Ubuntu? Detailed Easy Steps<\/title>\n<meta name=\"description\" content=\"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Clear Cache in Ubuntu? Detailed Easy Steps\" \/>\n<meta property=\"og:description\" content=\"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-13T07:34:00+00:00\" \/>\n<meta name=\"author\" content=\"Ujwala\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ujwala\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/\",\"name\":\"How to Clear Cache in Ubuntu? Detailed Easy Steps\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2025-06-13T07:34:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/485f82549b85b9f4c82dc208c42964a8\"},\"description\":\"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Clear Cache in Ubuntu? Detailed Easy Steps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/485f82549b85b9f4c82dc208c42964a8\",\"name\":\"Ujwala\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d26ea4b9b2d83ae90b67f6bf5eefbca?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d26ea4b9b2d83ae90b67f6bf5eefbca?s=96&d=blank&r=g\",\"caption\":\"Ujwala\"},\"description\":\"My aim is to create enriching content on topics related to SEO, web hosting and social media. The idea is to elevate the readers to new levels of usability, accessibility and understanding.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/ujwala\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Clear Cache in Ubuntu? Detailed Easy Steps","description":"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/","og_locale":"en_GB","og_type":"article","og_title":"How to Clear Cache in Ubuntu? Detailed Easy Steps","og_description":"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2025-06-13T07:34:00+00:00","author":"Ujwala","twitter_misc":{"Written by":"Ujwala","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/","name":"How to Clear Cache in Ubuntu? Detailed Easy Steps","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2025-06-13T07:34:00+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/485f82549b85b9f4c82dc208c42964a8"},"description":"Need to free up space or fix network issues? Follow these simple steps to clear DNS and system cache in Ubuntu safely.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-clear-cache-in-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Clear Cache in Ubuntu? Detailed Easy Steps"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/485f82549b85b9f4c82dc208c42964a8","name":"Ujwala","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d26ea4b9b2d83ae90b67f6bf5eefbca?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d26ea4b9b2d83ae90b67f6bf5eefbca?s=96&d=blank&r=g","caption":"Ujwala"},"description":"My aim is to create enriching content on topics related to SEO, web hosting and social media. The idea is to elevate the readers to new levels of usability, accessibility and understanding.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/ujwala\/"}]}},"views":0,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/16834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=16834"}],"version-history":[{"count":2,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/16834\/revisions"}],"predecessor-version":[{"id":16837,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/16834\/revisions\/16837"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=16834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=16834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=16834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}