One of the main duty of System Administrator is monitoring and checking the disk usage. According to situation take action against it.
df command is used to file system disk space usage. It is practical to see disk usage in a fast and clean way.
Getting Help About df
We can get help about df with –help parameter. Keep in mind that -h is used for formatting operation.
How To Use Linux df Command with Examples?
$ df --help
Display Information About File System With df
If we do not provide any option or parameter the
df command will list all partitions and related information. We have explained the related information below the screenshot.
- Filesystem is the mount point of filesystem
- 1K-blocks is number of 1Kilobyteblocks
- Used is how many of the blocks are used
- Available is how many of the blocks are free
- Use % is usage percentage
- Mounted on is where the file system mounted
Display All File Systems with df
Previous examples will list only real file systems. But as we know that Linux creates a lot of pseudue file systems for its functionality. We can list all file systems even pro, sysfs. lxc related file systems are displayed too.
$ df -a
Display File Systems By Specifying Memory Block Size with df
Default block size is set to 1KB as we seen before. We can change this size whatever we want. Here we change to it 100 with -B option.
$ df -B 100
Print Size As Human Readable with df
We have not 50-100 kb of file system. Today file systems are very huge in size and reading these sizes as kb is complex so we prefer human readable GB sizes. We will use
-h option to list more readable format.
$ df -h
Show Total of The File Systems with df
We can sum up total size of the file systems with –total .At the end of list a new column named total added
$ df -h --total
List Inodes Count with df
Inodes are fundamental part of the file systems. Up to now we have used 1K blocks but we may show the total inode numbers about file systems with
-i option like below.
$ df -i
Print File System Type with df
File systems are We can also list file system type with df with -T option.
$ df -T
As we see there is tmpfs,ext4,xfs file systems in the screenshot.
List Only Local File Systems with df
There may be remote or network based file systems those are all ready mounted into the local Linux system. We can list only local file system by using -l option. Remote file systems like smb, nfs are not listed.
$ df -l
Filter Results According to File System with df
There are different type of file systems in a regular Linux system. We can filter results according to file system. This will provided with -t option.
$ df -t ext4
Sort File System According To Usage Percentage
We can sort the file system usage with sort command like below.
$ df -Ph | sort -nk5
Get Block Size Always in GB with df
We may want to list sizes in GB for all ways. By using
-BG option df will always output GB.
$ df -BG