Linux df Command: Check Disk Space Usage
The df command in Linux (disk free) shows the used capacity of a file system in terms of space and inodes.
An inode is a data structure that describes a file system object, which can be one of several things, including a file or directory. Each inode stores the attributes and block location(s) of the object's data. File system object attributes can include metadata (last change, access, and modification times), as well as ownership and permission data (for example, group id, user id, permissions).
Since the number of inodes is directly linked to the number of files a device can store, they may run out and we may still have disk space available. This is rare, but can happen when we have a huge number of small files. The number of inodes is defined when the disk is formatted.
It can receive as a parameter the file system you want information about. If no file name is provided, df shows the available space on all currently mounted file systems. Disk space is shown in 1K blocks by default.
In this example df shows the capacity of the disk mounted as root /:
$ df /Sist. Arq. 1K-blocos Usado Disponível Uso% Montado em/dev/mapper/cl-root 42954248 8079412 34874836 19% /
The -i option of df shows the amount of available inodes:
$ df -i /Sist. Arq. Inodes IUsado ILivr IUso% Montado em/dev/mapper/cl-root 21487616 174290 21313326 1% /
Reading the occupied and available space can be done more easily with the -h option:
$ df -h /Sist. Arq. Tam. Usado Disp. Uso% Montado em/dev/mapper/cl-root 41G 7,8G 34G 19% /
Without specifying a file, df shows information about all mounted disks:
$ df -hSist. Arq. Tam. Usado Disp. Uso% Montado emdevtmpfs 979M 0 979M 0% /devtmpfs 996M 0 996M 0% /dev/shmtmpfs 996M 420K 996M 1% /runtmpfs 996M 0 996M 0% /sys/fs/cgroup/dev/xvda1 8,0G 4,7G 3,4G 58% //dev/xvdf 20G 12G 7,4G 61% /hometmpfs 200M 0 200M 0% /run/user/1000
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
And why not also get an LPI Linux Essentials certification while you're at it? And even better, with the best Online Course for Linux?
That was just one piece. The course teaches the whole path — from your first command to exam day.