A full disk is one of the most common reasons an Ubuntu server misbehaves. Websites stop accepting uploads, databases refuse writes, updates fail halfway, and sometimes the system will not even boot cleanly. The good news is that checking disk space on Ubuntu takes seconds, once you know the right commands. In this guide you will learn five commands that answer every disk-space question: how much space is left, which folders are eating it, and which files you can safely remove.

This tutorial is written for Ubuntu 24.04 and 22.04, and every command works on both desktop and server editions. You only need a terminal and, for some commands, sudo access.

Prerequisites

  • An Ubuntu 22.04 or 24.04 system (server or desktop).
  • Access to a terminal. On a server, connect over SSH.
  • Sudo privileges for checking system directories and installing the optional ncdu tool.
  • No extra software is required for the first four commands; they are all built into Ubuntu.

Step 1: See overall usage with df

The df command (disk free) is the first command to run whenever space looks tight. It shows every mounted filesystem, its total size, how much is used, and how much is free.

df -h

The -h flag means human-readable, so sizes appear in GB and MB instead of raw blocks. Look at the Use% column for your root filesystem, usually mounted on /. Anything above 85% deserves attention, and above 95% is urgent: many services start failing before the disk hits 100%.

For one extra useful detail, add the filesystem type:

df -hT

The -T flag adds a Type column, so you can tell ext4 partitions apart from tmpfs mounts, snap loop devices, and network shares. Ignore tmpfs and loop entries when hunting for real disk usage; they are not consuming your hard drive.

Step 2: Find the biggest directories with du

Once df tells you the disk is full, du (disk usage) tells you where the space went. Start at the root and list the largest top-level directories:

sudo du -h --max-depth=1 / 2>/dev/null | sort -hr | head -20

Here --max-depth=1 limits the output to one level deep, sort -hr puts the biggest entries first, and head -20 keeps the list readable. The 2>/dev/null part hides permission errors from directories your user cannot read.

Drill into the biggest offender, usually /var, /home, or /usr:

sudo du -h --max-depth=1 /var 2>/dev/null | sort -hr | head -20

Repeat this step, moving one level deeper each time, until you reach the folder that actually holds the bulk. To check a single folder quickly, use:

du -sh /var/log

The -s flag summarizes the whole folder into one total instead of listing every subdirectory, and -h keeps it human-readable.

Step 3: Explore interactively with ncdu

Reading du output gets tedious on a large server. ncdu (NCurses Disk Usage) gives you the same information as a navigable, sorted list you can browse with arrow keys and Enter.

sudo apt update && sudo apt install -y ncdu

This installs ncdu from Ubuntu's official repositories. Then scan the whole disk:

sudo ncdu /

Use the up and down arrows to move, Enter to enter a directory, and d to delete a selected file or folder (it asks for confirmation first). Press q to quit. Because ncdu sorts by size, the biggest space hogs are always at the top, which makes it the fastest way to answer "what is filling my disk?" on an unfamiliar server.

Step 4: Find the biggest individual files with find

Sometimes one giant file is the culprit: a forgotten backup, a runaway log, or a database dump. The find command locates files over a given size anywhere on the disk:

sudo find / -xdev -type f -size +1G -exec ls -lh {} \; 2>/dev/null

The -xdev flag keeps the search on the root filesystem (it skips mounted external drives), -type f limits results to files, and -size +1G means larger than 1 GB. The output shows each file's size and path, so you can judge immediately whether it is safe to delete, compress, or move.

To find the ten largest files regardless of size threshold, combine find with sort:

sudo find / -xdev -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10

This is especially useful when no single file is huge but a handful of multi-hundred-megabyte files add up.

Step 5: Check block devices and inodes with lsblk and df -i

Two edge cases catch people out. First, a disk can look fine in df while a partition is mounted somewhere unexpected. List all block devices to see the real layout:

lsblk -f

This shows disks, partitions, mount points, and filesystem types in a tree view, so you can spot an unmounted data disk or a partition mounted at the wrong place.

Second, a disk can report free space yet still refuse new files. That happens when inodes, the filesystem's per-file metadata slots, run out. Millions of tiny files (for example, an out-of-control cache or session directory) can exhaust inodes while barely using any bytes. Check with:

df -i

If the IUse% column for / is near 100%, you have an inode problem, not a byte problem. The fix is deleting large numbers of small files, typically old cache, session, or thumbnail files, rather than hunting for one big file.

Free up space safely

Once you know what is consuming space, reclaim it carefully. These commands are safe on a standard Ubuntu system:

sudo apt autoremove -y
sudo apt autoclean
sudo journalctl --vacuum-size=200M

The first removes packages that were installed as dependencies and are no longer needed. The second clears old package files from the local cache. The third trims the systemd journal to 200 MB, which is often the single biggest quick win on a long-running server; journal logs can silently grow to several gigabytes.

Only delete files you recognize. Never delete anything under /bin, /sbin, /lib, or /etc to free space, and never delete a database's live data directory. When in doubt, move the file to a backup location first and delete it after confirming the system still works.

Verify it worked

After cleanup, run df again and compare the Use% column with your first reading:

df -h /

Checking just / gives a one-line summary of your root filesystem. You should see the Use% drop and the Avail column grow. If the number barely moved, re-run the du scan from Step 2: the real consumer may be a second large directory you have not cleaned yet. For a quick before-and-after record, save the output to a file before and after cleanup and compare the two.

Common issues and fixes

df shows 100% but du cannot find the space

This usually means a deleted file is still held open by a running process, most often a log file deleted while a service still writes to it. The space only frees when the process closes the file. Restart the service, or find the open deleted files with sudo lsof | grep deleted and restart the listed process.

Permission denied errors flood du output

This is normal when running du as a regular user, since system directories are unreadable. Re-run with sudo and add 2>/dev/null to silence the remaining warnings, as shown in Step 2.

The disk fills up again within days

A recurring fill points to a runaway process: an application logging errors in a loop, or a backup job writing to the wrong directory. Use du -sh /var/log and the find command from Step 4 to identify the growing file, then fix the application or set up log rotation instead of repeatedly deleting files by hand.

ncdu is not found after installing

On minimal server images the package lists may be stale. Run sudo apt update first, then install again. If the server has no internet access, skip ncdu entirely: the du commands in Step 2 give the same information.

Conclusion

Checking disk space on Ubuntu comes down to a simple workflow: df for the big picture, du or ncdu to find the heavy directories, find for oversized files, and lsblk plus df -i for the edge cases. Run these commands the moment a server feels slow or an update fails, and a full disk stops being a crisis and becomes a five-minute fix.

If your team spends more time firefighting servers than building products, XpertBees can help: our engineers manage Ubuntu servers, monitoring, and backups for growing businesses, so disk-full alerts get handled before they become downtime.