How to check disk size and usage in Linux
Partitions and disks are bound to get full if not properly managed. It is therefore essential to continually monitor the current utilization and the remaining free space of your filesystem.
Some Linux distributions install specific directories such as /var and /home into different partitions. While there are benefits to that approach, it also adds more failure points and increases the chance that any disks or partitions run out of free space independently.
Related: How to clear disk space on Linux
A common tool used in Linux to monitor disk utilization is df. It's a command-line application and can check for the filesystem's size, usage, and available space. It is, however, can't be used to check the size of specific files and folders.
Steps to check disk utilization and free space in Linux:
-
Launch terminal.
-
Show disk / partition size, usage and available space usage using df.
$ df Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 399740 1800 397940 1% /run /dev/sda3 19991152 7696980 11255632 41% / tmpfs 1998688 0 1998688 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 4096 0 4096 0% /sys/fs/cgroup /dev/sda2 524272 7984 516288 2% /boot/efi tmpfs 399736 108 399628 1% /run/user/1000
-
Show usage and available space using df in human readable format.
$ df -h Filesystem Size Used Avail Use% Mounted on tmpfs 391M 1.8M 389M 1% /run /dev/sda3 20G 7.4G 11G 41% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup /dev/sda2 512M 7.8M 505M 2% /boot/efi tmpfs 391M 100K 391M 1% /run/user/1000
Unit changed to M(Megabyte), G(Gigabyte), T (Terabyte) etc instead of in blocks.
-
Show disk usage information for a specific partition.
$ df -h /dev/sda3 Filesystem Size Used Avail Use% Mounted on /dev/sda3 20G 7.4G 11G 41% /
-
Show disk usage information for a specific mount point.
$ df -h /boot/efi Filesystem Size Used Avail Use% Mounted on /dev/sda2 512M 7.8M 505M 2% /boot/efi
-
Show disk usage in more format and details using different options for df.
$ df -hT Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 391M 1.8M 389M 1% /run /dev/sda3 ext4 20G 7.4G 11G 41% / tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup /dev/sda2 vfat 512M 7.8M 505M 2% /boot/efi tmpfs tmpfs 391M 112K 391M 1% /run/user/1000
-
Utilize more options for df command to check disk size and usage in Linux.
$ df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M) -H, --si print sizes in powers of 1000 (e.g., 1.1G) -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) --output[=FIELD_LIST] use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted. -P, --portability use the POSIX output format --sync invoke sync before getting usage info --total elide all entries insignificant to available space, and produce a grand total -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit Display values are in units of the first available SIZE from --block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on. FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page). GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Full documentation <https://www.gnu.org/software/coreutils/df> or available locally via: info '(coreutils) df invocation'
Related: df man page