free_field - Linux


Overview

free_field is a Linux command that calculates and displays the total and available disk space on all mounted file systems. It provides a concise overview of storage usage, making it useful for monitoring disk space and identifying potential storage issues.

Syntax

free_field [OPTIONS]

Options/Flags

| Flag | Description | Default |
|—|—|—|
| -b | Display sizes in bytes | false |
| -d | Display Directories’ Names | false |
| -f | Display Free Space only | false |
| -g | Display sizes in gigabytes | false |
| -m | Display sizes in megabytes | false |
| -s | Display sizes in human-readable format (e.g., 1GB, 200MB) | true |
| -t | Display total disk space and overall usage | false |
| -u | Display sizes in units of 1000 bytes (e.g., 1K, 200M) | false |

Examples

Display disk space usage in human-readable format:

free_field

Show only free disk space in gigabytes:

free_field -f -g

Display total disk space and overall usage:

free_field -t

List directories’ names along with free space in human-readable format:

free_field -d -s

Common Issues

  • Incorrect permissions: Ensure that the user running the command has read permissions on the mounted file systems.
  • No output: If the command does not display any output, check for errors by running it with the -d flag.
  • Negative disk space: This usually indicates a filesystem error and should be investigated further.

Integration

Combine with ‘df’: df -h | free_field -sd provides a detailed overview of disk usage, including both file systems and directories.
Use in scripts: free_field -f -g | awk '{print $2}' can be used in scripts to extract free space in gigabytes.

Related Commands

  • df: Displays disk usage information, including file systems and usage percentages.
  • lsblk: Lists available block devices and their properties, including mount points and sizes.
  • du: Estimates file space usage, allowing for more granular inspection of directories and files.