Updated: 12 October 2026 · Applies to: Ubuntu 24.04 (GNU coreutils 9.4), Ubuntu 26.04 (uutils coreutils 0.10.0 for du and ls, GNU df 9.7), AlmaLinux 10 (GNU 9.5) and Debian 13 (GNU 9.7)
To check disk usage in Linux, run df -h: it shows the size, used space and free space of every disk. To show the size of a directory, run du -sh followed by the folder: du -sh /var/www, or du -sh . for the directory you are in. To see the size of every file and folder inside a directory, run du -sh *. For a single file, ls -lh file shows its size in K, M or G. These commands work the same on Ubuntu, Debian, AlmaLinux, Rocky Linux and RHEL.
df -h # used and free space on every disk du -sh . # size of the current directory du -sh /path/to/dir # size of any directory du -sh * # size of each item in the current directory ls -lh file.zip # size of one file
The du and ls examples below were run on Debian 13 in a test folder /srv/site. Ubuntu 24.04, Ubuntu 26.04 (which uses the Rust uutils version of du and ls) and AlmaLinux 10 printed exactly the same results.
1. Check disk usage of the whole disk: df
du adds up files; df asks each file system how full it is:
$ df -h Filesystem Size Used Avail Use% Mounted on overlay 48G 14G 32G 30% / tmpfs 64M 0 64M 0% /dev shm 63M 0 63M 0% /dev/shm tmpfs 764M 70M 695M 10% /etc/hosts devtmpfs 4.0M 0 4.0M 0% /proc/keys
Lab output from our Debian 13 test container (Ubuntu 24.04, Ubuntu 26.04 and AlmaLinux 10 showed the same). On a VPS or dedicated server the main line shows a partition such as /dev/sda1 or /dev/vda1 instead of overlay. Read the line mounted on / (and /home or /var if separate): a Use% near 100% means that disk is almost full. tmpfs, devtmpfs and shm live in memory, not on the disk.
df -h /var/www: only the file system that holds this folder.df -hT: adds the file system type, such as ext4 or xfs.df -h -x tmpfs -x devtmpfs: hides the memory file systems.lsblk: the disks and partitions themselves, so you can spot disk space that no partition uses yet (see disk space allocated in Linux).
On ext4, Size minus Used is more than Avail because, according to the mke2fs manual, 5% of the blocks are reserved for root by default.
"No space left on device" while df shows free space? Check the inodes with df -i: every file uses one, and a file system without free inodes refuses new files. On a small ext4 test disk (64 inodes) under a real Linux kernel (user-mode Linux 6.12), the 53rd file failed while 55M was still free:
touch: cannot touch '/srv/data/f52': No space left on device $ df -h /srv/data Filesystem Size Used Avail Use% Mounted on /dev/ubda 59M 46K 55M 1% /srv/data $ df -i /srv/data Filesystem Inodes IUsed IFree IUse% Mounted on /dev/ubda 64 64 0 100% /srv/data
To find the folder with the most files, run du --inodes -x -d 1 / | sort -n | tail (tested on GNU and uutils du); cache, session and mail queue folders are frequent causes.
2. Size of the current directory
$ cd /srv/site $ du -sh . 71M .
-s (summarize) prints one total instead of a line for every subfolder, and -h (human-readable) prints 71M instead of a number of 1 KiB blocks. du -sh with no folder name also means the current directory. For another folder, give its path: du -sh /srv/site/uploads. Run it with sudo if some subfolders belong to other users; otherwise du prints cannot read directory ... Permission denied and leaves them out of the total.
3. Size of the files and folders in a directory
- Every item in the current directory:
$ du -sh * 51M backups 4.0K cache 4.0K index.php 724K logs 18M uploads
*skips hidden items such as.git. Add them and sort smallest to largest:$ du -sh -- * .[!.]* | sort -h 4.0K cache 4.0K index.php 724K logs 2.9M .git 18M uploads 51M backups
- Only the subfolders one level down (hidden ones included), largest first, with the total on top:
$ du -h -d 1 | sort -hr 71M . 51M ./backups 18M ./uploads 2.9M ./.git 724K ./logs 4.0K ./cache
-d 1is short for--max-depth=1. Use-d 2to go one level deeper. - Files only, sorted by size, with
ls:$ ls -lhS uploads total 17M -rw-r--r-- 1 root root 15M Oct 9 10:15 video.mp4 -rw-r--r-- 1 root root 2.0M Oct 9 10:15 photo.jpg
4. Size of a single file
$ ls -lh uploads/video.mp4 -rw-r--r-- 1 root root 15M Oct 9 10:15 uploads/video.mp4 $ stat -c %s uploads/video.mp4 15728640 $ du -h uploads/video.mp4 15M uploads/video.mp4
ls -lh is the quickest check. stat -c %s prints the exact size in bytes, which is handy in scripts (wc -c < file gives the same number). Do not use ls -l on a folder to measure it: the 4096 you see next to a directory is the size of the directory entry itself, not of its contents.
$ ls -ld uploads drwxr-xr-x 2 root root 4096 Oct 9 10:15 uploads
5. Why du, ls and df sometimes disagree
ls shows the apparent size (how many bytes the file says it has); du shows how much disk space it really uses. They differ for sparse files such as virtual machine disk images and some database files:
$ du -sh cache; ls -lh cache/sparse.img; du -h --apparent-size cache/sparse.img 4.0K cache -rw-r--r-- 1 root root 1.0G Oct 9 10:15 cache/sparse.img 1.0G cache/sparse.img
The 1 GB image takes only 4 KB on disk. Add --apparent-size (or -b for bytes) when you want the size a download or a copy to another system would have. Two more things that make numbers differ:
-hcounts in powers of 1024;--sicounts in powers of 1000. The same file is15Mwithdu -hand16Mwithdu -sh --si.- A deleted file that a running program still holds open keeps using disk space that
dfcounts butducannot see. In our test a deleted 20 MB log leftdu -shat 4.0K, andlsof +L1(packagelsof) found it:$ lsof +L1 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME bash 1 root 3r REG 0,47 20971520 0 1572891 /srv/logs/app.log (deleted)
(output shortened). Restarting that program frees the space.
6. Totals, filters and exclusions
$ du -ch uploads/*.jpg uploads/*.mp4 2.0M uploads/photo.jpg 15M uploads/video.mp4 17M total $ du -h --threshold=10M 18M ./uploads 51M ./backups 71M . $ du -sh --exclude=backups . 21M .
-cadds a total line for a group of files.--threshold=10Mhides folders smaller than 10M. The old trickdu | awk '$1 > 10000'does the same in 1 KiB blocks (the quotes must go around$1 > 10000with no braces).--excludeleaves out matching names, for example backups ornode_modules.- The five biggest items anywhere under the current folder:
du -ah . | sort -hr | head -n 5. - Files over a size, with
find:find . -type f -size +10M -exec ls -lh {} +.
7. Ubuntu desktop and interactive tools
- On the Ubuntu desktop, right-click a file or folder in Files and choose Properties, or select it and press Alt+Enter. According to GNOME's help, a file shows its Size and a folder shows its Contents. For large folders,
du -shin a terminal is faster (see how to open a terminal in Ubuntu). ncduscans a folder once and lets you browse it with the arrow keys, sorted by size, and delete from inside it (ncdu -ropens it read-only). Install it withsudo apt install ncduon Ubuntu and Debian, orsudo dnf install ncduon AlmaLinux and Rocky Linux afterdnf install epel-release. Then runncdu /var; add-xto stay on one file system.
On cPanel hosting you can see the same numbers without SSH: check disk usage of a directory in cPanel. For a deeper hunt for what is filling a server, see find the largest files and directories in Linux, top directories and files by disk space and the useful switches for du.
Official documentation: GNU du invocation and GNU df invocation.