Skip to content

Introduction to the df Command in Linux

The df command in Linux is used to display information about disk space usage on file systems. It provides a quick and easy way to monitor available and used disk space, making it an essential tool for system administrators and users managing storage in the ChromeOS Linux Environment (Crostini).

Syntax and Usage

The basic syntax of the df command is as follows:

df [options] [file]
  • file: An optional argument to specify a file or directory for which to display disk usage.
  • options: Flags to modify the behavior of the df command.

Common Use Cases

  1. Display disk usage for all file systems:

    df
    
  2. Display disk usage in human-readable format:

    df -h
    

    This formats the output using units like KB, MB, or GB for easier readability.

  3. Show file system type:

    df -T
    
  4. Display only file systems of a specific type (e.g., ext4):

    df -t ext4
    
  5. Exclude file systems of a specific type (e.g., tmpfs):

    df -x tmpfs
    
  6. Check disk usage for a specific directory:

    df -h /path/to/directory
    

Useful Options

  • -h: Human-readable format.
  • -T: Display file system type.
  • -t: Display only specified file system types.
  • -x: Exclude specified file system types.
  • --total: Display a grand total of all listed file systems.

Special Notes for ChromeOS Linux Environment

In ChromeOS Linux, the df command works similarly to other Linux distributions. However, be aware of the following:

  • The Crostini container operates within a limited storage allocation, which can be monitored using df.
  • Shared file systems, such as those under /mnt/chromeos/, might show different usage patterns due to their integration with the host system.

Running df -h regularly can help ensure that your Linux container does not run out of storage, especially if you are working with large files or installing multiple packages.

Conclusion

The df command is a valuable tool for monitoring and managing disk space usage in Linux. Its simplicity and versatility make it an essential part of any Linux user’s toolkit, especially in storage-constrained environments like ChromeOS Crostini.