df command – df stands for disk free – when used presents with details of disk space used and available in Linux system. By default, file system shows size in bytes of all partition including ones which are inaccessible. The df command is very flexible, you can customize output of filesystem size, include or exclude specific filesystem type.
df [options] [device]
Use of df command in Linux with examples
Check filesystem disk space
The most basic use of df command is to check filesystem disk space. This can be done simply using df command on terminal.
The output displays details for file system device names, disk blocks, total disk space used, available disk space, percentage of usage and mount points on a file system.
Check filesystem disk usage in more usable format (Human readable)
By default, df shows disk usage size in bytes. 1024 bytes will combine to form 1 Kilobyte, 1024 kilobytes combine to form 1 Megabyte and so on. It becomes difficult to understand sizes when displayed in bytes. Most modern system display disk utilization in Kb’s, Mb’s and Gb’s. When df command is used with switch -h displays size human readable format.
Display disk usage in different size formats
As already mentioned df command is very flexible in terms of usage. df command allows user to display size in bytes, Kilobyte, Megabyte and Gigabyte.
Display disk usage in Kilobytes
Using -k switch with df command displays size with basic block size of 1024 bytes.
Display disk usage in Megabytes
Using -m switch with df command displays size with basic block size of 1024 kilobytes.
Display disk usage in Gigabytes
Using -h switch with df command displays size with basic block size of 1024 Megabytes.
Display filesystem type
Default output of df command does not display filesystem type, to display filesystem type use -T switch.
Include certain filesystem type
To display only certain type of file system use switch -t with df command along with filesystem
df -t [filesystem type]
df -t ext3
Exclude certain filesystem type
To exclude only certain type of file system use switch -x with df command along with filesystem
df -x [filesystem type]
df -x ext3
This command will show all filesystem other than ext3.
Display size of a mount point
Using -h switch with a mount point in df command displays disk space utilization of mount point.
df -h /home
This command will display space utilization for home.
Display local file system only
By default, when df command is executed it shows space utilization for all mounted file systems including NFS, Samba shares. To display only local filesystem you will have to use –local or -l switch.