Over time, every operating system accumulates unnecessary files, and Ubuntu is no exception. Between cached package files, old kernels, and leftover dependencies, your hard drive can quickly fill up. If you are experiencing low storage warnings, learning how to clean up disk space in Ubuntu Linux safely is an essential maintenance skill that will restore your system’s performance.
Unlike Windows, you rarely need third-party cleaning software in Linux. By running a few simple commands in the terminal, you can reclaim gigabytes of space in seconds.
1. Remove Unused Software Dependencies
When you install an application in Ubuntu, the package manager (APT) often installs additional libraries and dependencies required for that program to run. However, when you uninstall the application later, those dependencies are frequently left behind. To remove them safely, run the autoremove command.
- Open your terminal (Ctrl + Alt + T).
- Type the following command and press Enter:
sudo apt autoremove - Type your administrator password if prompted.
- The terminal will list all the orphaned packages and ask if you want to remove them. Type Y and press Enter to free up the space.
2. Clear the APT Cache
Every time you download a software update, Ubuntu stores a copy of the installation file (.deb) in a cache folder. Over the years, this cache can grow to an enormous size. Once the software is installed, you no longer need these cached files.
- Open the terminal.
- To completely clear out all cached packages, type:
sudo apt clean
Note: This command is completely safe and will not uninstall any software you are currently using.
3. Clean Up Systemd Journal Logs
Ubuntu keeps a detailed log of system events for troubleshooting purposes. While this is helpful for developers, average users do not need gigabytes of old log data sitting on their hard drive.
- First, check how much space your logs are currently taking up by typing:
journalctl --disk-usage - To shrink the logs and delete anything older than 3 days, type:
sudo journalctl --vacuum-time=3d
4. Empty the GUI Trash Bin
If you use the graphical interface rather than the terminal, deleting files simply moves them to the Trash bin, meaning they still occupy disk space.
- Open your Files application.
- Click on Trash in the left sidebar.
- Click the Empty button in the top right corner to permanently delete the files and reclaim your storage.
Knowing how to clean up disk space in Ubuntu ensures your system remains snappy and efficient. By routinely running autoremove and clearing your APT cache, you can prevent unnecessary bloat and keep your Linux environment running smoothly.