df command tutorial in linux/unix with examples and use cases

linux df command – report file system disk space usage

linux df command displays the amount of disk space available on the file system containing each file name argument.  If no file name is given, the space available on all currently mounted file systems is shown. 

If you need to check the file or folder storage space, you can use the linux du command.

Syntax

 df [OPTION]... [FILE]...

Options

  • -a, –all
    include pseudo, duplicate, inaccessible 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
  • -h, –human-readable
        print sizes in powers of 1024 (e.g., 1023M)
  • -H, –si
    print sizes in powers of 1000 (e.g., 1.1G)
  • -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
  • –total
    elide all entries insignificant to available space, and produce a grand total
  • -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
  • –output[=FIELD_LIST]
    use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.

Examples & Use Cases

Show disk space available

In the following example, we will use the df command to display disk free space in a human-readable manner.

➜  df -h

Show disk free space in GB

In the following example, we use the df -BG option to display disk free space in GB.

➜  df -BG

Add a Comment

Your email address will not be published.