Check what’s consuming all your disk space quickly and easily
We can use the
du command to find what’s using up all your disk space
List folders and their disk usage, including subdirectories
$ du -h 671M ./Arch Linux 6.5G ./Debian-based/Kali Linux 9.4G ./Debian-based/Ubuntu 17G ./Debian-based 415M ./Gentoo 11G ./RHEL-based/AlmaLinux 14G ./RHEL-based/CentOS 1.9G ./RHEL-based/Fedora 27G ./RHEL-based 44G .
List root folders and their disk usages
du -h --max-depth=1
du -h --max-depth=1 671M ./Arch Linux 17G ./Debian-based 415M ./Gentoo 27G ./RHEL-based 44G .
--max-depth parameter can be used to limit subfolder lists to any level desired
Sort by disk usage
Pipe the output of the
du -h command into the
sort command to get the list sorted by disk usage. This can be used in conjunction with
--max-depth as well
du -h | sort -h
$ du -h | sort -h 415M ./Gentoo 671M ./Arch Linux 1.9G ./RHEL-based/Fedora 6.5G ./Debian-based/Kali Linux 9.4G ./Debian-based/Ubuntu 11G ./RHEL-based/AlmaLinux 14G ./RHEL-based/CentOS 17G ./Debian-based 27G ./RHEL-based 44G .
Check over all disk usage of the system
df command can be used to check the overall disk usage and the available disk space on a system
df -h Filesystem Size Used Avail Use% Mounted on /dev/mmcblk0p1 28G 18G 8.2G 69% / none 16G 0 16G 0% /dev tmpfs 16G 88K 16G 1% /dev/shm tmpfs 16G 118M 16G 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/nvme0n1 458G 44G 391G 11% /mnt/nvme0n1 tmpfs 3.2G 24K 3.2G 1% /run/user/1000
-T option to list the filesystem type of the disks as well