df Command in Linux (With Examples)

The Linux command-line utility, df (disk free), is used to display the free disk space of a specific file system. There are options available to display the text you want, as well as filenames or directories to provide information on their filesystems.

Note: Linux commands featured in this article are distro-independent, meaning they will work on any Linux distro.

df Command Syntax

The df command displays the amount of free space on the file system containing each file name. If no filename is provided, the free space on all mounted file systems is displayed. The syntax of the df command is as follows.

# df [option] [file]

df Columns

These are the columns usually displayed with the df command.

  • File System – name of the disk partition.
  • Size – total size of the file system.
  • Used – total amount of space allocated to existing files on the file system.
  • Available – total amount of space available on the file system.
  • Percentage Used – percentage of the available space allocated to files in the file system.
  • Mounted On – directory where the file system appears.

df Command Real-Life Scenarios

While many options are available with the df command, we’ll only review those most used by Linux admins and users.

  1. If no file name is given, df displays all the space available on all currently mounted file systems:
    # df

    Output of df.
    The output of df.

  2. If you specify a particular file directory or a file, df shows the mount information of that file or directory:
    # df filename

    The output of df /home/techobservatory.
    The output of df /home/techobservatory.

  3. To display all mounted filesystems in human-readable format:
    # df -h

    The output of df -h.
    The output of df -h.

  4. You can also use options together with the df command. For example, to see your mounted file systems, excluding temporary systems (tmpfs), in human-readable format:
    # df -hx tmpfs

    The output of df -hx tmpfs.
    The output of df -hx tmpfs.

Leave a Comment