This tutorial explains Linux “df” command, options and its usage with examples.
DESCRIPTION
Report how much free disk space is available for each mount you have.
SYNOPSIS
df [OPTION]… [FILE]…
OPTIONS
-a, –all
include dummy file systems
-B, –block-size=SIZE
use SIZE-byte blocks
-h, –human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
-H, –si
likewise, but use powers of 1000 not 1024
-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)
-P, –portability
use the POSIX output format
–sync
invoke sync before getting usage info
-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
EXAMPLES
1. Simple Example showing usage of df command
# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 78361192 23185840 51130588 32% / /dev/cciss/c0d0p5 24797380 22273432 1243972 95% /home /dev/cciss/c0d0p3 29753588 25503792 2713984 91% /data /dev/cciss/c0d0p1 295561 21531 258770 8% /boot tmpfs 257476 0 257476 0% /dev/shm
2. Display Information of all File System Disk Space Usage
It also displays information of dummy file systems along with all the file system disk usage and their memory utilization.
# df -a Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 78361192 23186116 51130312 32% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts /dev/cciss/c0d0p5 24797380 22273432 1243972 95% /home /dev/cciss/c0d0p3 29753588 25503792 2713984 91% /data /dev/cciss/c0d0p1 295561 21531 258770 8% /boot tmpfs 257476 0 257476 0% /dev/shm none 0 0 0 - /proc/sys/fs/binfmt_misc sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
3. Display Disk Space Usage in Human Readable Format
It is done using -h option.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/cciss/c0d0p2 75G 23G 49G 32% / /dev/cciss/c0d0p5 24G 22G 1.2G 95% /home /dev/cciss/c0d0p3 29G 25G 2.6G 91% /data /dev/cciss/c0d0p1 289M 22M 253M 8% /boot tmpfs 252M 0 252M 0% /dev/shm
4. Display Information of /home
The output is also in human readable format and type is also displayed using the -T option.
# df -hT /home Filesystem Type Size Used Avail Use% Mounted on /dev/cciss/c0d0p5 ext3 24G 22G 1.2G 95% /home
5. Display Information of File System in Bytes
To display all file system information and usage in 1024-byte blocks
# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 78361192 23187212 51129216 32% / /dev/cciss/c0d0p5 24797380 22273432 1243972 95% /home /dev/cciss/c0d0p3 29753588 25503792 2713984 91% /data /dev/cciss/c0d0p1 295561 21531 258770 8% /boot tmpfs 257476 0 257476 0% /dev/shm
6. Display Information of File System in MB
-m option is used for displaying information in MB.
# df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 76525 22644 49931 32% / /dev/cciss/c0d0p5 24217 21752 1215 95% /home /dev/cciss/c0d0p3 29057 24907 2651 91% /data /dev/cciss/c0d0p1 289 22 253 8% /boot tmpfs 252 0 252 0% /dev/shm
7. Display File System Inodes
# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/cciss/c0d0p2 20230848 133143 20097705 1% / /dev/cciss/c0d0p5 6403712 798613 5605099 13% /home /dev/cciss/c0d0p3 7685440 1388241 6297199 19% /data /dev/cciss/c0d0p1 76304 40 76264 1% /boot tmpfs 64369 1 64368 1% /dev/shm
Using ‘-i‘ switch will display the information of number of used inodes and their percentage for the file system.
8. Display File System Type
File system type is displayed using -T option.
# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 ext3 78361192 23188812 51127616 32% / /dev/cciss/c0d0p5 ext3 24797380 22273432 1243972 95% /home /dev/cciss/c0d0p3 ext3 29753588 25503792 2713984 91% /data /dev/cciss/c0d0p1 ext3 295561 21531 258770 8% /boot tmpfs tmpfs 257476 0 257476 0% /dev/shm
9. Exclude Certain File System Type
For example, the following command will only display other file systems types other than ext3.
# df -x ext3 Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 257476 0 257476 0% /dev/shm
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Practice Programming MCQs
- Buy Linux Books
- Apply for Programming Internship
- Apply for Linux Internship
- Buy Information Technology Books