# Cheatsheet & Examples: df

## Basic Disk Usage Report

Example Usage:
`df`

What it does:
Displays the amount of disk space used and available on all mounted filesystems, using default units (blocks) and summarizing the data.

Command-line Arguments Explained:

- None: No arguments provided, so `df` defaults to showing disk usage for all filesystems in blocks.

## Human-Readable Disk Usage

Example Usage:
`df -h`

What it does:
Shows disk usage in a human-readable format, using units like KB, MB, and GB instead of raw block counts.

Command-line Arguments Explained:

- `-h`: Enables human-readable output, converting block sizes to easily understandable units.

## Show All Filesystems

Example Usage:
`df -a`

What it does:
Displays disk usage for all filesystems, including virtual ones like `tmpfs` or `proc`, which are usually excluded by default.

Command-line Arguments Explained:

- `-a`: Includes all filesystems in the output, even those that are typically not shown (e.g., virtual or special-purpose filesystems).

## Disk Usage in Specific Units

Example Usage:
`df -k` or `df -m`

What it does:
Displays disk usage in kilobytes (`-k`) or megabytes (`-m`) instead of the default block size.

Command-line Arguments Explained:

- `-k`: Uses kilobytes as the unit for display.
- `-m`: Uses megabytes as the unit for display.

## Filter by Filesystem Type

Example Usage:
`df -t ext4`

What it does:
Shows disk usage information only for filesystems of the specified type (e.g., `ext4`).

Command-line Arguments Explained:

- `-t`: Filters the output to display only filesystems of the given type (e.g., `ext4`, `xfs`, `ntfs`).

## Exclude Specific Filesystem Types

Example Usage:
`df --exclude-type=tmpfs`

What it does:
Excludes filesystems of the specified type (e.g., `tmpfs`) from the disk usage report.

Command-line Arguments Explained:

- `--exclude-type`: Filters out filesystems of the given type from the output.

## Inode Usage Statistics

Example Usage:
`df -i`

What it does:
Displays information about inode usage rather than block usage, showing how many inodes are used and available.

Command-line Arguments Explained:

- `-i`: Shows inodes (file metadata) usage instead of disk space usage.

## Custom Output Fields

Example Usage:
`df --output=source,fstype,size,used,avail`

What it does:
Customizes the output to show specific fields (e.g., device source, filesystem type, size, used space, available space).

Command-line Arguments Explained:

- `--output`: Specifies which fields to display in the output. Available fields include `source`, `fstype`, `size`, `used`, `avail`, `capacity`, `mountpoint`, and more.

## Disk Usage Summary

Example Usage:
`df --summarize`

What it does:
Provides a summary line at the end of the output, showing the total used and available space across all mounted filesystems.

Command-line Arguments Explained:

- `--summarize`: Adds a summary line to the output, summarizing disk usage for all filesystems.

## Disk Usage with Specified Block Size

Example Usage:
`df --block-size=1M`

What it does:
Displays disk usage in the specified block size (e.g., megabytes) instead of the default.

Command-line Arguments Explained:

- `--block-size`: Sets the block size for display. Valid values include `1K`, `1M`, `1G` (kilobytes, megabytes, gigabytes), or any numeric multiplier.

## Help and Usage Instructions

Example Usage:
`df --help`

What it does:
Displays a help message with usage instructions and available options for the `df` command.

Command-line Arguments Explained:

- `--help`: Shows a summary of how to use `df` and lists its available options.

## Version Information

Example Usage:
`df --version`

What it does:
Outputs the version of the `df` utility installed on the system.

Command-line Arguments Explained:

- `--version`: Displays the version number of `df`, confirming the implementation (GNU coreutils, macOS, etc.).
