Linux

Disk Usage Analysis in Linux: A Complete Guide

This guide will help you master essential tools for analyzing disk space in Linux, from basic commands to interactive utilities. You'll learn to locate large files and folders to free up space and optimize your system.

Updated at February 16, 2026
15-30 min
Medium
FixPedia Team
Применимо к:All modern Linux distributionsUbuntu 20.04+CentOS 7+Debian 10+

Introduction / Why This Is Needed

Disk space filling up is a common problem in Linux systems that can lead to slowdowns, application errors, and even system boot failures. Analyzing disk usage allows you to quickly identify which files and folders occupy the most space and take steps to clean them up. In this guide, you will master the essential tools for analyzing disk space: from simple commands to interactive utilities.

Requirements / Preparation

Before you begin, ensure that:

  • You have access to a Linux terminal (via SSH or locally).
  • For some commands (e.g., searching the entire system), superuser privileges (root or sudo) are required.
  • Basic utilities are installed (they are usually present by default). If not, we will show how to install additional ones.

Step-by-Step Instructions

Step 1: Check Overall Disk Usage with df

The df (disk free) command shows the usage of each mounted filesystem partition. This gives a general idea of which partitions are nearly full.

df -h

The key flag -h (human-readable) outputs sizes in convenient units (KB, MB, GB). Pay attention to the Use% column—the usage percentage. If it is close to 100%, the partition needs to be cleaned.

Step 2: Analyze Folder Sizes with du

After identifying a full partition, you need to find which folders within it take up the most space. For this, use du (disk usage).

du -h --max-depth=1 /path/to/partition

For example, for the home directory:

du -h --max-depth=1 /home

This command will show the size of each first-level folder in /home. The --max-depth=1 parameter limits the depth to avoid cluttering the output. You can change the depth or specify a particular folder.

Step 3: Install ncdu for Interactive Analysis

For a more convenient analysis, install ncdu (NCurses Disk Usage). This is a console utility with an interactive interface that allows you to quickly navigate the filesystem and see sizes.

Installation:

Ubuntu/Debian:

sudo apt update && sudo apt install ncdu

CentOS/RHEL:

sudo yum install ncdu

Launch:

ncdu /path/to/partition

In the ncdu interface, you can navigate with arrow keys, press Enter to enter folders, and d to delete files (be careful!). This is an excellent way to explore disk usage in detail.

Step 4: Find the Largest Files in the System

Sometimes the problem lies in a few huge files (logs, caches, ISO images). To find them, use a combination of find, du, and sort.

sudo find / -type f -exec du -h {} + | sort -rh | head -n 20

Explanation:

  • sudo find / — search for files starting from the root (requires privileges).
  • -type f — only files (not folders).
  • -exec du -h {} + — for each file, output its size.
  • sort -rh — sort in descending order (human-readable).
  • head -n 20 — take the top 20.

Be cautious: searching the entire disk can take a long time and create load. You can limit the path, for example, to /home.

Step 5: Use Graphical Tools if Necessary

If you are working in a graphical environment (GUI), there are convenient visualizers:

  • Baobab (for GNOME): shows disk usage as a ring chart or tree. Installation: sudo apt install baobab (Ubuntu/Debian). Launch from the applications menu or with baobab.
  • Filelight (for KDE): a similar utility that creates a clear disk map. Installation: sudo apt install filelight (Ubuntu/Debian) or via Discover.

These tools are especially useful for beginners.

Verifying the Result

After completing the steps, you should:

  • Know which partitions are full (via df).
  • Understand which folders occupy the most space (via du or ncdu).
  • Be able to locate specific large files (via find).
  • Use graphical tools if necessary.

If you have freed up space, run df -h again to confirm that the usage percentage has decreased.

Potential Issues

  • Access errors (Permission denied): Many commands, especially when searching from root, require sudo. If you see errors, try adding sudo (but be careful with deletion).
  • Slow find performance on the entire disk: limit the path. For example, specify /home or /var instead of /.
  • ncdu not installed: install it via the package manager as shown above.
  • Different space reporting: df shows space per filesystem (including reserved space), while du shows actual usage. This is normal, and the difference can be 5–10% (reserved for root).

Additional Tips

  • Regularly check logs in /var/log—they can grow large.
  • Clean package caches: sudo apt clean (Ubuntu/Debian) or sudo yum clean all (CentOS).
  • Remove old kernels (if there are many) via dpkg --list | grep linux-image and sudo apt purge linux-image-old-version.
  • Use journalctl --disk-usage to check systemd journal usage and journalctl --vacuum-size=100M to clean it up.

These tips will help you keep disk space under control.

F.A.Q.

How to quickly find which folders take up the most space?
What's the difference between df and du?
How to find the largest files in the system?
Are there graphical tools for disk analysis?

Hints

Check overall disk usage with df
Analyze folder sizes with du
Install ncdu for interactive analysis
Find the largest files in the system
Use graphical tools if needed
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