How to free up space on Ubuntu Server


So you have been running your Ubuntu Server for a while and recently found out that the disk usage is already at 70%!? Then lets free some space up.

This tutorial will help you liberate space on your system without breaking anything in the process.

Before we start


While this tutorial is focused on Ubuntu Server, it can be used for many other distributions that use the same packages, like Ubuntu Desktop, Debian, Linux Mint, etc.


  • An Ubuntu server
  • Access to your server

Clean packages

Packages are archived and stored, if these versions can’t be downloaded anymore — because there is a newer version or any other reason — , they end up being unnecessary. So lets clean lingering packages.

# Find no longer available packages and remove them
sudo apt autoclean -y

Remove packages

Chances are that when you update and upgrade your system, some packages end up being unnecessary. But your system won’t remove them, so lets tell it to do that.

# Find unnecessary or redundant packages and remove them
sudo apt autoremove -y


Application logs keep increasing the disk usage of your server, specially if it is a busy one. But if we don’t care much about keeping records, we can just delete them.

# Check current logs disk usage
sudo journalctl --disk-usage
# Rotate logs so they are saved to disk
sudo journalctl --rotate
# Clean any log that is older than one second
sudo journalctl --vacuum-time=1s
# One liner
sudo journalctl --rotate && sudo journalctl --vacuum-time=1s

Biggest files

Now we are switching to a more manual approach, lets find out what the biggest files on our system are.

# Find biggest files in "/" and show their size in human readable format
sudo du -a -h /
# Sort the output
sort -n -r
# Show only the top 15 results
head -n 15
# Combined in a one liner
sudo du -a -h / | sort -n -r | head -n 15

And then delete them

# Delete a file
sudo rm /path/to/file

⚠ Be careful to not delete any important file, in case of doubt, don’t do it. ⚠



You can now search for more specific guides.

For example, if you are using Docker, you might want to learn how to remove unnecessary images or containers.

Self promotion

If you have found this useful then you should follow me, I will be posting more interesting content! 🥰

Or support me financially. 💸

Originally published at




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Integrate Admob Rewarded Ad Swift

How to improve your integration tests so they can serve as documentation for your application

WaW — AWS Redshift

Windows 7 Nvidia Edition Serial Key

How to release Unity Editor Tools on the Unity Asset Store

Master Data and Reference Data

Design your automated tests to scale for keeps

Unity3D crashes at EditorApplication.update startup — potential fix

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alejandro Akbal

Alejandro Akbal


More from Medium

creating a service in linux using systemd

PiHole, Docker and Google Nest adventures 👩‍💻

Server Hardening with OpenSCAP

content of /usr/share/xml/scap/ssg/content/ directory

Install L2TP over IPsec with Freeradius on Ubuntu