Time to Free up Space on Ubuntu.

mtee

Margaret W.N

Posted on September 24, 2020

Time to Free up Space on Ubuntu.

Out of Space? Welcome to the club. Time for some space hunt. Here are some techniques that came through for me, today. You might want to start with the last one, it will save you so much work.

  • Remove all unused packages.
sudo apt-get autoremove
Enter fullscreen mode Exit fullscreen mode
  • Clear the APT cache.

Check the cache size:

sudo du -sh /var/cache/apt 
Enter fullscreen mode Exit fullscreen mode

Clear cache

sudo apt-get clean
Enter fullscreen mode Exit fullscreen mode
  • Clear systemd journal logs. This freed up a good amount of space.

Check the space occupied:

journalctl --disk-usage
Enter fullscreen mode Exit fullscreen mode

Clean out some logs. You might want to read about this: Clearing systemd journal logs in linux. But if you are in dire need of space and have no time, use the command below. It will clear all the logs older than 2 days.

sudo journalctl --vacuum-time=2d
Enter fullscreen mode Exit fullscreen mode
  • Remove older versions of Snap applications Check the space occupied
du -h /var/lib/snapd/snaps
Enter fullscreen mode Exit fullscreen mode

Create a script file, add the lines below, and save. I saved mine as script.sh on Home directory.

set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
    while read snapname revision; do
        snap remove "$snapname" --revision="$revision"
    done
Enter fullscreen mode Exit fullscreen mode

Give the file execute permissions

chmod 0700 script.sh
Enter fullscreen mode Exit fullscreen mode

Run the script to remove older packages.

sudo ./script.sh
Enter fullscreen mode Exit fullscreen mode
  • Uninstall apps you don't use. Stop saving them for the future! Easy for me to say but this was hard for me. I resorted to deleting everything I haven't used in the past two months, or anything with an online alternative.

All the above freed up about 3 to 4 GB, then came the mother of all space eaters, my trash! Quite embarrassing and funny cause I did not think of the trash at all until I installed Stacer and the analytics were screaming at me: Take out the trash!

  • Install Stacer and let the system cleaner do the work for you. You can search ubuntu software or use the command below to install.
 sudo apt install stacer
Enter fullscreen mode Exit fullscreen mode

That's it for day 70: 100 days of code
Lets do this again tommorrow

馃挅 馃挭 馃檯 馃毄
mtee
Margaret W.N

Posted on September 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related