Introduction to the df command

Introduction to the df command

The df (disk free) command is a very useful command-line utility that can be used to check the amount of disk space available on a given filesystem or disk partition. It can also be used to check the size of the files and directories stored on the filesystem.

Basic usage and syntax

The basic syntax for the df command is:

df [options] [filesystem]

The options can be used to customize the output of the command, such as specifying the format of the output, or the units of measurement. The filesystem parameter is used to specify the filesystem or disk partition to be examined.

Examples of common use cases

  • To check the disk space available on the root filesystem:
    df /
  • To check the disk space available on all mounted filesystems:
    df -h
  • To check the disk space available on a specific filesystem:
    df -h /home

Advanced options and flags

The df command has a number of advanced options and flags that can be used to customize the output of the command. Some of these options include:

  • -a: Show all file systems, including those with 0 blocks.
  • -B: Display output in bytes.
  • -h: Display output in human-readable format (e.g. K, M, G, etc).
  • -i: Display inode information.
  • -l: Display only local file systems.
  • -P: Display output in POSIX-compliant format.
  • -T: Display filesystem type.
  • -x: Display output in a single line.

Troubleshooting tips and potential errors

The most common error when using the df command is the “No such file or directory” error, which usually occurs when the filesystem parameter is incorrect or does not exist. To troubleshoot this error, check the filesystem parameter and make sure it is correct.

Additional resources for further learning

For more information about the df command, please refer to the following resources:

0 Comments