<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ved G. Acharya on Medium]]></title>
        <description><![CDATA[Stories by Ved G. Acharya on Medium]]></description>
        <link>https://medium.com/@vedgacharya?source=rss-4df102c51944------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DAe0TADi2mBCeZJO</url>
            <title>Stories by Ved G. Acharya on Medium</title>
            <link>https://medium.com/@vedgacharya?source=rss-4df102c51944------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 15:03:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vedgacharya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Free up space on Ubuntu: The Easy Way]]></title>
            <link>https://medium.com/@vedgacharya/free-up-space-on-ubuntu-the-easy-way-0aeda1e288d5?source=rss-4df102c51944------2</link>
            <guid isPermaLink="false">https://medium.com/p/0aeda1e288d5</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[shell-script]]></category>
            <category><![CDATA[free-disk-space]]></category>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[linux-disk-space]]></category>
            <dc:creator><![CDATA[Ved G. Acharya]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 19:55:03 GMT</pubDate>
            <atom:updated>2024-06-29T19:55:03.291Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a simple, step-by-step guide on using the terminal to remove garbage files from Ubuntu to free up space. This should work on any Ubuntu-based Linux distribution as well as Linux Mint.</p><p>Additionally, I’ve included a shell script at the end that should make performing a disk clean on your Ubuntu computer as simple as copying, pasting, saving, and running two commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TA-YtQ_fniJRgqh_MxXB6Q.jpeg" /><figcaption>I clicked this pic. Do not feel free to copy this.</figcaption></figure><h3>You can follow along in 2 ways:</h3><ol><li>Step-by-step guide</li><li>One-shot: Do It All</li></ol><h3>1. Step-by-step guide</h3><h4>Good riddance of unwanted packages</h4><p>If you’ve been using Ubuntu, you have undoubtedly used the <em>apt-get</em> commands. It helps in installing packages and libraries.</p><p>The following <em>apt-get</em> command eliminates packages that were installed as program dependencies but were left in place when the program they were dependent on was deleted.</p><pre>sudo apt-get autoremove</pre><h4>Cleaning <em>APT</em> cache</h4><p>As APT carries out the installation, upgradation, and removal of packages, it keeps a cache of DEB packages. If this cache is left unchecked, it can grow quite a bit.</p><p>To check the current cache size, use the <em>du</em> command:</p><pre>sudo du -sh /var/cache/apt</pre><p>This <em>apt-get</em> command will purge the APT cache folder:</p><pre>sudo apt-get clean</pre><p>You can check with the <em>du</em> command as to how much difference it makes.</p><h4>Clearing the System Journal Logs</h4><p>Cleaning out the Linux logs can make a significant difference. Yes, these are essential to investigate what’s going on in your system, but over time these logs end up eating up a lot of system space.</p><p>You can check how much disk space the system journal logs are taking using:</p><pre>journalctl --disk-usage</pre><p>To clean out these system journal logs, carry out:</p><pre>sudo journalctl --vacuum-time=3d</pre><p>If you are having the itch to go check what’s the change in disk usage, feel free to do so using the previous journalctl --disk-usage command</p><h4>Cleaning out the thumbnails</h4><p>This ain’t much, but it’s honest work.</p><pre>rm -rf ~/.cache/thumbnails/*</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*O-iFMcJIUKZ9d-DA.jpg" /><figcaption>Just a meme for the fun of it</figcaption></figure><p>This might not be significant, but it’s something.</p><h4>Removing older versions of SNAP applications</h4><p>SNAP packages are usually bigger in size which in turn ends up eating a lot of disk space, and to add to the ginormous package sizes, it also ends up storing up to two older versions of the packages.</p><p>I don’t use SNAP as my package installer for most applications, but if you do, this should help out:</p><ol><li>Close off all your SNAPS (SNAP applications)</li><li>Open a text editor</li><li>Copy-paste this code from Alan Pope from the Snapcraft team at Canonical (the company that produces Ubuntu)</li></ol><pre>#!/bin/bash<br># Removes old revisions of snaps<br># CLOSE ALL SNAPS BEFORE RUNNING THIS<br>set -eu<br>snap list --all | awk &#39;/disabled/{print $1, $3}&#39; |<br>    while read snapname revision; do<br>        snap remove &quot;$snapname&quot; --revision=&quot;$revision&quot;<br>    done</pre><p>4. Save this <em>shell </em>file in a decent place with the extension <em>.sh</em>, for example <em>&lt;filename&gt;.sh</em>. For my machine, I’ve created a <em>scripts</em> folder in the <em>home</em> directory and placed it there.</p><p>5. Open the folder location of this file or navigate to it using the <em>cd</em> command on your terminal. At the end, your terminal should be open where this file is saved.</p><p>6. Give this file execution permission by running <em>chmod</em></p><pre>chmod +x &lt;filename&gt;.sh</pre><p>7. Then you should be able to run this file using <em>sudo</em> to clear out the junk that SNAP ends up creating</p><pre>sudo ./&lt;filename&gt;.sh</pre><p>If you’re too lazy, like I am. The next method is to execute all these commands in one go by writing out a shell script, like you just did.</p><h3>2. One-shot: Do It All</h3><p>Every time you have the urge to clear up space on Ubuntu, all this approach does is combine the earlier methods into a bundle that is served in a single line to the terminal.</p><ol><li>Open up your text editor.</li><li>Copy-paste this and save it at a decent location with the file extension of <em>.sh</em> as this is a shell script.</li></ol><pre>#!/bin/bash<br># Removes old revisions of snaps<br># CLOSE ALL SNAPS BEFORE RUNNING THIS<br><br>set -eu<br>snap list --all | awk &#39;/disabled/{print $1, $3}&#39; |<br>while read snapname revision; do<br>    snap remove &quot;$snapname&quot; --revision=&quot;$revision&quot;<br>done<br><br># Vacuum old journal logs older than 3 days<br>journalctl --vacuum-time=3d<br><br># Remove unnecessary packages<br>apt-get autoremove -y<br><br># Clean up APT cache<br>apt-get clean<br><br># Remove cached thumbnails<br>rm -rf ~/.cache/thumbnails/*</pre><p>3. Use the cd command on your terminal to get to the file’s location, or open the folder location and then right-click in a free space to <em>Open in Terminal</em>. At the end, your terminal should be open where this file is saved.</p><p>4. Give this file execution rights</p><pre>chmod +x &lt;filename&gt;.sh</pre><p>5. Run this file using <em>sudo</em></p><pre>sudo ./&lt;filename&gt;.sh</pre><h3>Yup, that’s it</h3><p>I hope this simple and easy guide helped out in freeing up space on your Ubuntu or Ubuntu-like machine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0aeda1e288d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>