How to check disk space in Linux command line. The command df shows you free disk space and du returns the disk usage statistics for various files and folders.
df command
The df command shows disk usage statistics and it stands for “Disk Free”.
The df command bellow without any options will return the disk size, disk used, available size, disk free percentage and mount point for all system partitions.
df
df Example
[dragos@localhost ~]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 900440 0 900440 0% /dev
tmpfs 929904 168 929736 1% /dev/shm
tmpfs 929904 82060 847844 9% /run
tmpfs 929904 0 929904 0% /sys/fs/cgroup
/dev/mapper/cl-root 39687236 8365356 31321880 22% /
/dev/sda2 1038336 370900 667436 36% /boot
/dev/mapper/cl-home 19372032 2332336 17039696 13% /home
/dev/sda1 613184 7404 605780 2% /boot/efi
tmpfs 185980 1184 184796 1% /run/user/42
tmpfs 185980 92 185888 1% /run/user/1004
[dragos@localhost ~]$
If you want to disk size is displayed in human readable format MB,GB,TB instead of bytes use the -h option.
df -h
df -h example
[dragos@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 880M 0 880M 0% /dev
tmpfs 909M 168K 908M 1% /dev/shm
tmpfs 909M 81M 828M 9% /run
tmpfs 909M 0 909M 0% /sys/fs/cgroup
/dev/mapper/cl-root 38G 8.0G 30G 22% /
/dev/sda2 1014M 363M 652M 36% /boot
/dev/mapper/cl-home 19G 2.3G 17G 13% /home
/dev/sda1 599M 7.3M 592M 2% /boot/efi
tmpfs 182M 1.2M 181M 1% /run/user/42
tmpfs 182M 92K 182M 1% /run/user/1004
[dragos@localhost ~]$
To see all partitons (pseudo, duplicate, inaccessible) use the -a option.
df -ah
df -a example
[dragos@localhost ~]$ df -ah
Filesystem Size Used Avail Use% Mounted on
sysfs 0 0 0 - /sys
proc 0 0 0 - /proc
devtmpfs 880M 0 880M 0% /dev
securityfs 0 0 0 - /sys/kernel/security
tmpfs 909M 168K 908M 1% /dev/shm
devpts 0 0 0 - /dev/pts
tmpfs 909M 81M 828M 9% /run
tmpfs 909M 0 909M 0% /sys/fs/cgroup
cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore 0 0 0 - /sys/fs/pstore
efivarfs 0 0 0 - /sys/firmware/efi/efivars
........
tmpfs 182M 92K 182M 1% /run/user/1004
gvfsd-fuse 0 0 0 - /run/user/1004/gvfs
tmpfs 909M 81M 828M 9% /run/netns
[dragos@localhost ~]$
To also see the file system type use df -T option. Disk free human readable and showing file system type also.
df -hT
df -T example
[dragos@localhost ~]$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 880M 0 880M 0% /dev
tmpfs tmpfs 909M 168K 908M 1% /dev/shm
tmpfs tmpfs 909M 81M 828M 9% /run
tmpfs tmpfs 909M 0 909M 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 38G 8.0G 30G 22% /
/dev/sda2 xfs 1014M 363M 652M 36% /boot
/dev/mapper/cl-home xfs 19G 2.3G 17G 13% /home
/dev/sda1 vfat 599M 7.3M 592M 2% /boot/efi
tmpfs tmpfs 182M 1.2M 181M 1% /run/user/42
tmpfs tmpfs 182M 92K 182M 1% /run/user/1004
[dragos@localhost ~]$
Most useful options for df.
-a, --all include pseudo, duplicate, inaccessible file systems
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
-T, --print-type print file system type
du command
The du command shows disk usage of directories and files. It’s useful to find folders and files that use a lot of disk space.
List all files and folders with their size in the current directory.
du -h
Show disk usage of all files
du -ah
ls
Lists folders and files and shows their size on disk, human readable.
ls -al
ls -alh
stat
Display the used disk space of a folder.
[dragos@localhost ~]$ stat /home/dragos
File: /home/dragos
Size: 219 Blocks: 0 IO Block: 4096 directory
Device: fd02h/64770d Inode: 33807434 Links: 8
Access: (0700/drwx------) Uid: ( 1004/ dragos) Gid: ( 1004/ dragos)
Access: 2021-09-15 11:05:28.795212138 +0300
Modify: 2021-09-15 10:12:34.093313726 +0300
Change: 2021-09-15 10:12:34.093313726 +0300
Birth: -
[dragos@localhost ~]$