loading...

Time to Free up Space on Ubuntu.

mtee profile image Margaret W.N ・2 min read

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
  • Clear the APT cache.

Check the cache size:

sudo du -sh /var/cache/apt 

Clear cache

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

Check the space occupied:

journalctl --disk-usage

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
  • Remove older versions of Snap applications Check the space occupied
du -h /var/lib/snapd/snaps

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

Give the file execute permissions

chmod 0700 script.sh

Run the script to remove older packages.

sudo ./script.sh
  • 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

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

Posted on by:

mtee profile

Margaret W.N

@mtee

Developer | GADs 20 scholar | Diving into backend

Discussion

pic
Editor guide
 

I tend to do the same processes. A little addition:

  • rm -rf ~/Dropbox/.dropbox.cache/*
  • Browser -> History -> Clear current history -> Cache
    • Clear browser cache
  • rm -rf ~/.var/app/REMOVED_APP
    • Data may remain after Snaps have been removed
  • rm -rf ~/.config/JetBrains/IntelliJIdeaPREVIOUS/
    • You can delete directories of previous versions of IDEA
  • Vagrant / VirtualBox: Move virtual machine to another drive
  • Run git prune in repositories
 

Awesome! I'll definitely try this. I might end up with more space. Thank you!

 
 
 

Your welcome

 

I really should take the time to read the journalctl documentation 😅 Awesome tips @mtee !

 

😂 You should, though times like this call for a quick fix.

I'm glad you found them useful 😊