The df command is used to show the amount of disk space that is free on file systems. In the examples, df is first called with no arguments. This default action is to display used and free file space in blocks. In this particular case, th block size is 1024 bytes as is indicated in the output.
In this article i will explain howto use df command through a few simple examples.
df command examples usage
If the df command is run without any arguments or options then it provides information about all the mounted file systems.
$ df
Print human readable sizes
By using “-h” option with df command, print sizes in human readable format. Means it prints size in GB,MB etc.
Display information of file system in MB
By using -h option along with df command show display information of all file system statistics in GB
$ df -h
Display information of file system in MB
By using -m option along with df command show display information of all file system statistics in MB:
$ df -m
Example output:
df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/sda5 23339 4872 17260 23% / none 1 0 1 0% /sys/fs/cgroup udev 1804 1 1804 1% /dev tmpfs 371 2 369 1% /run none 5 0 5 0% /run/lock none 1851 2 1850 1% /run/shm none 100 1 100 1% /run/user /dev/sda7 59733 5474 51203 10% /home
Show all mounted filesystem including dummy filesystem
Using -a option with df command, prints all filesystems including dummy filesystem.
$ df -a
Example output:
$ df -a Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 23899004 4988564 17673400 23% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys none 4 0 4 0% /sys/fs/cgroup none 0 0 0 - /sys/fs/fuse/connections none 0 0 0 - /sys/kernel/debug none 0 0 0 - /sys/kernel/security udev 1847220 4 1847216 1% /dev devpts 0 0 0 - /dev/pts tmpfs 378968 1232 377736 1% /run none 5120 0 5120 0% /run/lock none 1894828 1136 1893692 1% /run/shm none 102400 16 102384 1% /run/user none 0 0 0 - /sys/fs/pstore /dev/sda7 61165596 5601496 52433940 10% /home binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc systemd 0 0 0 - /sys/fs/cgroup/systemd gvfsd-fuse 0 0 0 - /run/user/1000/gvfs /dev/sda2 51097596 38579520 12518076 76% /media/rasho/D056F85856F840B0 /dev/sda3 102399996 1656392 100743604 2% /media/rasho/Podaci
List Inodes
[ads]
By using -i option along with df command, print the inode information of filesystem.
$ df -ih
Example output:
$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda5 1525920 168952 1356968 12% / none 473707 2 473705 1% /sys/fs/cgroup udev 461805 518 461287 1% /dev tmpfs 473707 541 473166 1% /run none 473707 1 473706 1% /run/lock none 473707 10 473697 1% /run/shm none 473707 16 473691 1% /run/user /dev/sda7 3899392 7463 3891929 1% /home
Print File System Type
If you wish to print the type of file system in the output, use -T option:
$ df -T
Output:
$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda5 ext4 23899004 4988568 17673396 23% / none tmpfs 4 0 4 0% /sys/fs/cgroup udev devtmpfs 1847220 4 1847216 1% /dev tmpfs tmpfs 378968 1232 377736 1% /run none tmpfs 5120 0 5120 0% /run/lock none tmpfs 1894828 1136 1893692 1% /run/shm none tmpfs 102400 16 102384 1% /run/user /dev/sda7 ext4 61165596 5602352 52433084 10% /home
You can also display file systems that belongs to certain type (Here, type of filesystem meaning is ext2,ext3,ext4,tmpfs,sysfs etc.). For example, the following command displays only ext4 file systems types.
$ df -t ext4
Output:
$ df -t ext4 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 23899004 4988568 17673396 23% / /dev/sda7 61165596 5603104 52432332 10% /home
Display information of /home filesystem
To see display information of /home filesystem type following command:
$ df -hT /home
Output:
$ df -hT /home Filesystem Type Size Used Avail Use% Mounted on /dev/sda7 ext4 59G 5.4G 51G 10% /home
That is all for now. For more information see df command manual page or help system.
$ df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include dummy file systems -B, --block-size=SIZE scale sizes by SIZE before printing them. E.g., '-BM' prints sizes in units of 1,048,576 bytes. See SIZE format below. --total produce a grand total -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 -v (ignored) --help display this help and exit --version output version information and exit