Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux See What Is Using Disk Space: Commands That Work

· 5 min read · Home Tech

In this article
  1. Check filesystem usage with df
  2. Find large directories with du
  3. Locate individual large files
  4. Use ncdu for an interactive view
  5. Understand why df and du can disagree
  6. Choose a safe way to reclaim space
  7. Frequently Asked Questions

To see what is using disk space on Linux, start with df -h to find full filesystems, then use du to identify large directories and files. For an interactive view, install and run ncdu; these tools answer different questions, so combining them is usually the fastest way to find what is consuming storage.

Check filesystem usage with df

df reports space available on mounted filesystems. Run:

df -h

The -h option formats sizes in readable units such as GiB. Check the Use% column to identify a filesystem nearing capacity, and the Mounted on column to see where it appears in the directory tree. For example, a full / filesystem is different from a full separate /home or /var filesystem: the affected mount determines which files can be contributing to that shortage.

To focus on a path, use df -h /var. This tells you which filesystem stores /var and how full it is, but it does not break usage down by folder. That is the job of du.

Find large directories with du

To see the sizes of directories immediately under the root directory, run:

sudo du -xhd1 / 2>/dev/null | sort -h

On common GNU/Linux systems, -h prints readable sizes, -d1 limits the report to one directory level, and -x stays on the same filesystem rather than crossing into other mounts. sort -h orders the results by size, smallest to largest, so the biggest entries appear at the bottom. The redirection hides permission errors; omit it if you want to see which locations could not be read.

Once a large directory stands out, inspect one level deeper. For instance:

sudo du -xhd1 /var 2>/dev/null | sort -h

Repeat with the largest subdirectory until you find the specific area responsible. You can also examine a single directory with du -sh /path/to/directory. Here, -s gives one summary total instead of listing its contents.

Options differ across implementations. The examples above use GNU du, which is standard on many Linux distributions. If a flag is rejected, check du --help or its manual page; a portable alternative for a one-level summary is du -h --max-depth=1 /path on GNU systems.

Locate individual large files

Directories show where space is grouped, while find can list files above a chosen size. For files larger than 1 GiB on a filesystem, use:

sudo find / -xdev -type f -size +1G -print 2>/dev/null

-type f selects regular files, -size +1G sets the threshold, and -xdev avoids descending into other filesystems. This finds candidates, not automatically disposable files. A large virtual-machine image, database, backup, or application asset may be required. Inspect the pathname and understand its purpose before taking action.

Use ncdu for an interactive view

ncdu is a terminal-based disk-usage browser. Install it using your distribution’s package manager—for example, sudo apt install ncdu on Debian or Ubuntu—and scan a chosen location:

sudo ncdu -x /

Use the displayed directory sizes to navigate toward the largest entries. The interface makes it easier to explore than repeatedly running du, especially on a server without a graphical desktop. Its scan may take time on a large filesystem, and permission restrictions can hide entries unless you run it with appropriate privileges. The -x option keeps the scan on one filesystem, as with the earlier examples.

Although some versions offer deletion from within the interface, treat that feature cautiously. Confirm exactly what a path contains before deleting it; using ncdu does not make a file safe to remove.

Understand why df and du can disagree

A common surprise is that df reports a nearly full filesystem, but the visible totals from du do not add up. One cause is a deleted file that a running process still has open. Its name has disappeared from the directory listing, so du cannot count it, but the filesystem cannot release its blocks until the process closes the file.

To look for open-but-deleted files, use sudo lsof +L1 if lsof is installed. Check the process and file details before deciding what to do. Restarting or otherwise safely stopping the process may release the space, but do not terminate an unfamiliar service blindly.

Other differences can come from permissions, filesystems mounted below the directory being scanned, reserved filesystem space, or files changing during a scan. Running du with elevated privileges can reveal otherwise unreadable directories. Using -x can make the scan easier to interpret by excluding separate mounts, but remember that those mounts need their own checks with df and du.

Choose a safe way to reclaim space

After identifying the consumer, decide whether it is genuinely removable. Check its owner and purpose, and prefer an application’s own cleanup or uninstall mechanism over manually deleting unfamiliar files. Useful places to investigate include old downloads, application caches, system logs, package-manager caches, and backups—but their cleanup procedures depend on the distribution and software involved.

  • For logs, use the system’s logging tools and retention settings rather than deleting active log files by hand.
  • For package caches, use the package manager’s cleanup command so it can remove files it understands.
  • For containers, virtual machines, and databases, use their management tools; files that look old may still be in use.
  • After cleanup, rerun df -h to confirm that the filesystem has more available space.

A file’s size is not proof that it is safe to delete. In particular, do not remove arbitrary files under /usr, /var/lib, or application data directories just because they are large. If unsure, look up the file’s package or service owner and consult the relevant documentation.

Frequently Asked Questions

What command shows disk usage in Linux?
Use df -h for free and used space by filesystem. Use du -sh /path for the total space used by a particular directory.

How do I find the biggest folders?
Run sudo du -xhd1 /path | sort -h on a system with GNU du. Start at /, then run it again inside the largest directory.

How can I find the largest files?
Try sudo find / -xdev -type f -size +1G -print. Change the size threshold as needed, and check each result before removing anything.

Why does df show more usage than du?
A deleted file still held open by a process is a common reason. Permission limits, mounted filesystems, and reserved space can also make the totals differ.

Does ncdu delete files?
It can provide deletion controls in some versions, but its main purpose is to inspect usage interactively. Verify a file’s purpose and consequences before deleting it, whether in ncdu or from the shell.