How to Check Disk Space in Linux: df, du, lsblk & What They Actually Show

Learn how to check disk space in Linux from the command line. Use df to check free space, du to check disk usage by folder, and find what is eating your storage, with real tested output and fixes for "No space left on device".

Published

Updated

Read time 11 min read

Reviewed byDeepak Prasad

How to Check Disk Space in Linux: df, du, lsblk & What They Actually Show

So you are wondering, how to check disk space in Linux from the command line? This guide shows you exactly that, using the two tools you will reach for 90% of the time, df (to check free space) and du (to check disk usage by folder), plus the commands that tell you what is eating your storage. Every command below was run on a live Ubuntu server and the output you see is the real, untouched result, including a root filesystem that is sitting at a worrying 93% full.

In Linux, checking disk space is a routine but critical task. You either want a quick overview of how much free space is left on each partition, or you are responding to a No space left on device error and need to find what is using up the disk. We will cover both, from a fast one-liner to a full investigation.


Quick reference: Linux disk space commands

Goal Command
Check free disk space (all filesystems) df -h
Check disk space with filesystem type df -hT
Check space on one mount point df -h /
Show real disks only (hide tmpfs) df -h -x tmpfs -x devtmpfs
Check inode usage (hidden "disk full") df -i
Disk usage of a folder (total) du -sh /path
Size of each subdirectory, sorted du -h --max-depth=1 /path | sort -rh
Biggest directories on one filesystem du -xh --max-depth=1 /mount | sort -rh
Find largest files find /path -xdev -type f -size +500M
Device and partition layout lsblk -e7
Size of systemd journal logs journalctl --disk-usage
Physical disk size (hardware) sudo fdisk -l

1. df command – check free and used disk space

The df command (short for disk free) is the first tool to reach for when you want to check disk space in Linux. It reports how much space is total, used and available on every mounted filesystem. The -h (human-readable) flag prints sizes in K, M and G instead of raw 1‑kilobyte blocks:

bash
df -h
text
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              847M  3.0M  844M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   43G   38G  3.0G  93% /
tmpfs                              4.2G     0  4.2G   0% /dev/shm
tmpfs                              5.0M  8.0K  5.0M   1% /run/lock
tmpfs                              4.2G   32M  4.2G   1% /tmp
/dev/sda2                          2.0G  222M  1.6G  13% /boot
tmpfs                              847M  204K  847M   1% /run/user/1000

The columns are: filesystem device, total Size, Used space, Available space, Use% (percentage used) and the Mounted on point. Here the root filesystem / is at 93% used with only 3.0G free, which is the partition we would investigate.

Show the filesystem type with df -hT

Add -T to print the filesystem type (ext4, xfs, tmpfs, etc.). This is useful to tell real disks apart from in-memory tmpfs mounts:

bash
df -hT
text
Filesystem                        Type     Size  Used Avail Use% Mounted on
tmpfs                             tmpfs    847M  3.0M  844M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      43G   38G  3.0G  93% /
tmpfs                             tmpfs    4.2G     0  4.2G   0% /dev/shm
/dev/sda2                         ext4     2.0G  222M  1.6G  13% /boot
/dev/sr0                          iso9660   51M   51M     0 100% /media/golinuxcloud/VBox_GAs_7.2.01

Show only real disks (hide tmpfs noise)

On modern systems the df output is cluttered with tmpfs pseudo-filesystems. Use -x to exclude one or more types so you see only the physical disks and partitions:

bash
df -h -x tmpfs -x devtmpfs
text
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv   43G   38G  3.0G  93% /
/dev/sda2                          2.0G  222M  1.6G  13% /boot
/dev/sr0                            51M   51M     0 100% /media/golinuxcloud/VBox_GAs_7.2.01

Check disk space on a single filesystem

If you only care about one mount point, pass its path. df -h / removes all guesswork about which line is the root filesystem:

bash
df -h /
text
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv   43G   38G  3.0G  93% /

Get a grand total across disks

Add --total to append a summary row that sums all listed filesystems, handy for a single "how much storage do I have left" number:

bash
df -h --total -x tmpfs -x devtmpfs
text
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv   43G   38G  3.0G  93% /
/dev/sda2                          2.0G  222M  1.6G  13% /boot
/dev/sr0                            51M   51M     0 100% /media/golinuxcloud/VBox_GAs_7.2.01
total                               45G   38G  4.6G  90% -

Check inode usage with df -i

A filesystem can report No space left on device even when df -h shows free space, because it has run out of inodes (one inode is consumed per file, directory or symlink). Use -i to check this, and watch the IUse% column:

bash
df -i
text
Filesystem                         Inodes  IUsed   IFree IUse% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 2818048 712525 2105523   26% /
tmpfs                             1083776      6 1083770    1% /run/lock
/dev/sda2                          131072    330  130742    1% /boot

Here the root filesystem uses only 26% of its inodes, so inode exhaustion is not the problem. If IUse% were at 100%, you would be out of inodes regardless of free bytes. You can see the full set of options on the man page of df command.


2. du command – check disk usage by folder

Once df tells you which filesystem is full, the du command (short for disk usage) tells you what is filling it. du estimates the space used by files and directories, giving you the flexibility to check disk space by folder in Linux.

Total size of a single folder

The most common use is du -sh, where -s summarizes to a single total and -h makes it human-readable:

bash
sudo du -sh /var/log
text
313M	/var/log

Size of each subdirectory, largest first

To find the heaviest subdirectory, list one level deep with --max-depth=1 and pipe it to sort -rh (the -h flag of sort understands human-readable sizes like 2K, 4M, 1G, and -r reverses to largest-first):

bash
sudo du -h --max-depth=1 /var/log | sort -rh | head
text
313M	/var/log
297M	/var/log/journal
2.0M	/var/log/sysstat
1.1M	/var/log/installer
320K	/var/log/apt
84K	/var/log/unattended-upgrades
36K	/var/log/cups

The result is immediate: of the 313M in /var/log, the systemd journal directory alone accounts for 297M, so that is where the cleanup effort should focus.

Show only files above a size threshold

du lists everything by default. Add --threshold (or -t) to print only entries larger than a given size, which is perfect for spotting big files quickly:

bash
sudo du -ah --threshold=1M /var/log | sort -rh | head
text
313M	/var/log
297M	/var/log/journal/22e961a5781c41b3bed7f02bb85a0a9b
297M	/var/log/journal
8.1M	/var/log/journal/.../system.journal
8.1M	/var/log/journal/.../user-1000@...journal~

You can find more options on the man page of du command. If you want to manipulate the output further, our guide on awk pairs well with du for custom reports.


3. Find what is eating your disk space (the df → du → find workflow)

When a server reports No space left on device, the reliable workflow is df → du → find: find the full filesystem, find the biggest directory on it, then find the biggest files. Staying on one filesystem matters, so use du -x to stop it from crossing into other mounts.

Step 1 – find the biggest top-level directories on the root filesystem:

bash
sudo du -xh --max-depth=1 / | sort -rh | head
text
38G	/
23G	/var
6.9G	/home
6.2G	/usr
489M	/root
15M	/opt
13M	/etc

/var is the clear culprit at 23G. You would then drill into it (sudo du -xh --max-depth=1 /var | sort -rh) and keep following the biggest branch.

Step 2 – list the largest individual files with find. The -xdev flag keeps the search on a single filesystem and -size +200M filters to files larger than 200 MB:

bash
sudo find / -xdev -type f -size +200M -printf '%s\t%p\n' | sort -rn | head
text
1073741824	/swap.img
724512768	/home/golinuxcloud/golinuxcloud-static/.git/objects/pack/pack-b78bd4f8....pack
635518976	/var/lib/snapd/snaps/gnome-46-2404_153.snap
541278208	/var/lib/snapd/snaps/gnome-42-2204_226.snap
414167040	/var/lib/snapd/snaps/mesa-2404_1165.snap
294649856	/var/lib/containerd/.../blobs/sha256/c6c3054e9f3b...

Now the heavy hitters are obvious: a 1 GB swap file, a large Git pack, cached snap packages and container blobs. Cleanup becomes a deliberate decision instead of guesswork.

Interactive alternative: ncdu

For an interactive, navigable view of disk usage, the ncdu (NCurses Disk Usage) tool is a favourite. It is not installed by default, so add it first:

bash
# Debian/Ubuntu
sudo apt install ncdu

# RHEL/Rocky/Fedora
sudo dnf install ncdu

Then run ncdu / and browse the tree with the arrow keys, deleting files with d. It is the easiest way to explore which directories are consuming the most space without memorising flags.


4. Check the systemd journal size

On systemd distributions the binary journal under /var/log/journal is one of the most common reasons a root filesystem quietly fills up, exactly as we saw above. Check its size directly with:

bash
journalctl --disk-usage
text
Archived and active journals take up 296.1M in the file system.

If it is large, cap it with sudo journalctl --vacuum-size=200M or sudo journalctl --vacuum-time=2weeks. For more on reading and filtering these logs, see our guide on journalctl.


5. lsblk command – device and partition layout

lsblk lists block devices in a tree, which is the clearest way to understand which partitions and logical volumes exist and where they are mounted. On a desktop the output is buried under dozens of snap loop devices, so use -e7 to exclude them (major number 7 = loop devices):

bash
lsblk -e7
text
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                         8:0    0   25G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0   23G  0 part
  └─ubuntu--vg-ubuntu--lv 252:0    0   43G  0 lvm  /
sdb                         8:16   0   20G  0 disk
└─ubuntu--vg-ubuntu--lv   252:0    0   43G  0 lvm  /
sdc                         8:32   0 15.7G  0 disk
sr0                        11:0    1 50.7M  0 rom  /media/golinuxcloud/VBox_GAs_7.2.01

This system has three disks (sda, sdb, sdc), and the root LVM volume is built across sda3 and sdb. You can also request custom columns including filesystem usage:

bash
lsblk -e7 -o NAME,SIZE,FSTYPE,FSAVAIL,FSUSE%,MOUNTPOINT
text
NAME                       SIZE FSTYPE      FSAVAIL FSUSE% MOUNTPOINT
sda                         25G
├─sda1                       1M
├─sda2                       2G ext4           1.6G    11% /boot
└─sda3                      23G LVM2_member
  └─ubuntu--vg-ubuntu--lv   43G ext4             3G    88% /
sdb                         20G LVM2_member
sdc                       15.7G
sr0                       50.7M iso9660           0   100% /media/golinuxcloud/VBox_GAs_7.2.01

To confirm where a path is mounted and its source device, findmnt is the cleanest option:

bash
findmnt /
text
TARGET SOURCE                            FSTYPE OPTIONS
/      /dev/mapper/ubuntu--vg-ubuntu--lv ext4   rw,relatime

For more ways to inspect mounted filesystems, see how to check mounted filesystems.


6. Check the physical disk size (hardware capacity)

The commands above report filesystem space. If instead you want the raw size of the physical disks attached to the machine, use fdisk -l and filter to the real /dev/sd* disks:

bash
sudo fdisk -l | grep -E "^Disk /dev/sd"
text
Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdc: 15.7 GiB, 16861716480 bytes, 32933040 sectors

fdisk is primarily for creating and modifying partitions, but -l is a quick way to confirm exact disk capacity. The parted command (sudo parted -l) and lsblk shown earlier give the same hardware view. To understand the different disk and interface types you might see, refer to our overview of disk types in Linux.


7. Troubleshooting: "No space left on device" with free space showing

This is the question that drives most disk-space searches, so here are the four real causes and how to confirm each one.

Cause 1 – Out of inodes. Run df -i; if IUse% is 100% you are out of inodes (usually millions of tiny cache or session files) even though df -h shows free bytes. Delete or archive the small files to recover.

Cause 2 – Deleted files still held open. If a process is still writing to a file you deleted, the kernel will not release the space until the process closes it. Find these with:

bash
sudo lsof +L1
text
COMMAND     PID         USER  FD   TYPE DEVICE SIZE/OFF NLINK   NODE NAME
gnome-she  7581 golinuxcloud  39u   REG    0,1    68403     0   1092 /memfd:mutter-shared (deleted)

The NLINK column at 0 and the (deleted) marker identify the file, and SIZE/OFF shows the space it is still holding. Restart the owning process, or reclaim the space without restarting by truncating the file descriptor: : > /proc/PID/fd/FD.

Cause 3 – Reserved blocks. ext2/3/4 filesystems reserve ~5% of space for root so the system stays usable when full. A normal user can hit "disk full" while that reserve is intact. Confirm it with:

bash
sudo tune2fs -l /dev/mapper/ubuntu--vg-ubuntu--lv | grep -iE "block count|reserved block count"
text
Block count:              11270144
Reserved block count:     511041

That is 511041 of 11270144 blocks (about 4.5%, ~2 GB at 4K blocks) reserved for root. You can lower it on data volumes with sudo tune2fs -m 1 /dev/....

Cause 4 – Files hidden under a mount point. If data was written to a directory and another filesystem was later mounted on top, the original files still consume space but are invisible. Compare df against du, or unmount suspect mounts and check what was underneath.


Summary

There are several ways to check disk space in Linux, but two commands do most of the work. Use the df command (df -h) to check free and used disk space across all mounted filesystems, and df -h / or df -hT when you want a single mount point or the filesystem type. Use the du command (du -sh /path and du -h --max-depth=1 /path | sort -rh) to check disk usage by folder and pinpoint what is consuming storage.

When a disk is actually full, follow the df → du → find workflow to move from the full filesystem to the biggest directory to the largest files. And when Linux reports No space left on device while still showing free space, check inodes with df -i, look for deleted-but-open files with lsof +L1, and remember the ext4 reserved-blocks pool. Layer in lsblk, findmnt and journalctl --disk-usage for a complete picture, and you can diagnose any disk space issue from the Linux command line with confidence.


Frequently Asked Questions

1. What is the command to check disk space in Linux?

Use df -h to check disk space in Linux. It prints a human-readable summary of every mounted filesystem with its total size, used space, available space and use percentage. To check a single mount point use df -h / and to also see the filesystem type use df -hT.

2. What is the difference between df and du?

df reports free and used space per mounted filesystem (the "how full is the disk" view), while du reports the disk usage of individual files and directories (the "what is using the space" view). You normally run df first to find the full filesystem, then du to find what is filling it.

3. How do I check free disk space in Linux?

Run df -h and read the Avail column. For just the root filesystem use df -h /. To hide tmpfs/devtmpfs pseudo-filesystems and see only real disks, run df -h -x tmpfs -x devtmpfs.

4. How do I check disk usage by folder in Linux?

Use du -sh /path/to/folder for a single total, or run du -h --max-depth=1 /path piped to sort -rh to list the size of each immediate subdirectory sorted largest first.

5. How do I find what is using my disk space in Linux?

Start with df -h to find the full filesystem, then run du -xh --max-depth=1 on that mountpoint piped to sort -rh to find the biggest directories (the -x flag keeps du on one filesystem). Finally use find /path -xdev -type f -size +500M to list the largest individual files.

6. Why does Linux show the disk is full when there is still free space?

Three common causes are inode exhaustion (check with df -i, IUse% at 100%), files that were deleted but are still held open by a running process (find them with sudo lsof +L1), and the ext4 reserved-blocks pool (about 5% reserved for root, visible with tune2fs -l).

7. How do I check the size of my disk (hardware) in Linux?

Use lsblk -e7 to see the device and partition layout with sizes, or sudo fdisk -l to print each physical disk and its exact size in bytes. These show the hardware capacity rather than filesystem free space.

8. How do I check disk space without root or sudo?

df -h, lsblk and du on directories you own all work as a normal user. You only need sudo when running du or find against system directories such as /var or /root that a normal user cannot read.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …