Linux

Ubuntu Disk Monitoring: Check and Free Up Space in 5 Minutes

Learn how to track disk usage in Ubuntu via the terminal and GUI tools. This guide helps you quickly locate and remove unnecessary files to free up system space.

Updated at April 6, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Ubuntu 20.04 LTSUbuntu 22.04 LTSUbuntu 24.04 LTSDebian-based distributions

Introduction / Why This Matters

A full disk in Ubuntu leads to system slowdowns, failed updates, and service startup errors. Regular monitoring helps you quickly identify hidden space consumers and prevent critical issues. In this guide, you’ll learn how to check storage usage via the terminal and graphical tools, locate the largest directories, and safely free up disk space.

Prerequisites / Preparation

You’ll need Ubuntu 20.04, 22.04, or a newer release to follow this guide. Most commands run in the default terminal without requiring additional software. For interactive directory analysis, we recommend the ncdu utility, which isn’t included in the base installation. Make sure you have access to an account with sudo privileges.

Step 1: Check Overall Disk Usage

First, assess the overall state of your file system. Open a terminal (Ctrl + Alt + T) and run:

df -h

The df (disk free) command displays all mounted partitions. The -h flag formats the output into human-readable units (GB/MB). Pay attention to the Used and Available columns, along with the / mount point. If root partition usage exceeds 85%, it’s time to hunt down large files.

Step 2: Find the Largest Files and Directories

To see exactly which directories are taking up space, use the du (disk usage) utility. The standard command recursively scans directories, but the output can be overwhelming. Filter the top 15 folders in your home directory:

du -h ~/ | sort -rh | head -n 15

The -h flag enables human-readable formatting, sort -rh sorts from largest to smallest, and head limits the output.

For a more convenient analysis, we recommend installing ncdu:

sudo apt update && sudo apt install -y ncdu

To scan the system root:

sudo ncdu /

The interface allows you to navigate directories using the arrow keys, delete files by pressing d, and refresh the data with u.

Step 3: Automatically Clear System Cache and Logs

After identifying large directories, it’s safest to start with system caches. The APT package manager stores downloaded .deb archives that are no longer needed for installation. Clear them with:

sudo apt clean

Next, remove automatically installed dependencies that are no longer required by any package:

sudo apt autoremove -y

The systemd system journal can also grow to several gigabytes. Check the current log size:

journalctl --disk-usage

If the size exceeds 1 GB, limit log retention to the last three days:

sudo journalctl --vacuum-time=3d

💡 Tip: Configure log rotation in /etc/systemd/journald.conf by changing the SystemMaxUse=200M parameter. This will prevent disk overflow in the future.

Verify the Results

After performing the cleanup, run df -h again and compare the values in the Available column for the root partition. The difference should match the amount of freed cache and log space. Also, ensure that key services (e.g., apache2, docker, or snapd) start without write errors. Run systemctl --failed to check the status of active services.

Troubleshooting

  • Operation not permitted error when deleting files. You are trying to modify files owned by root or other services. Always use sudo for system directories, and do not delete contents in /etc or /usr without understanding their purpose.
  • ncdu shows 0 size or hangs on /proc and /sys. These virtual file systems do not consume disk space. Run ncdu with the -x flag to exclude pseudo-filesystems and network shares from the scan: sudo ncdu -x /.
  • Disk space isn't freed after cleanup. Files may have been deleted but are still held open by active processes. Reboot the system or locate these lingering processes using sudo lsof +L1 and restart the corresponding services.

F.A.Q.

Why is my disk space running out even though I haven't deleted anything?
How do I check the size of specific folders in the terminal?
Is it safe to delete the contents of `/tmp` and `/var/cache/apt/archives/`?

Hints

Check Overall Disk Status
Find the Largest Directories
Analyze and Clean Package Cache
Monitor System Logs
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community