quota - Linux


Overview

The quota command in Linux is used to check the disk usage and limits for a user or group. It helps users and administrators monitor and manage disk space usage by providing clear reports on how much space is occupied and how much is still available under the assigned quotas. This command is particularly useful in multi-user environments and in situations where disk space needs to be rationed effectively.

Syntax

The basic syntax of the quota command is as follows:

quota [options] [user|group]
  • [user|group]: Optionally specify a username or group to check the quota for. If not provided, the quota for the current user is displayed.

Options/Flags

  • -u, –user: Display quota for the user. This is the default if no type is specified.
  • -g, –group: Show the group quota.
  • -q, –quiet: Do not display any message if the user is within their disk quota.
  • -v, –verbose: Show more information, like the block size and detailed usage for all filesystems.
  • -i, –inode: Shows inode information (number of inodes being used).
  • -b, –block: Display blocks used, which is also the default display method.
  • –no-autofs: Skip autofs mount points.
  • –show-mntpoint: Show the mount point associated with each displayed quota.

Examples

  1. Check your own disk usage and limits:

    quota
    
  2. Check disk usage and limits for a specific user:

    quota -u username
    
  3. Check disk usage and limits for a specific group:

    quota -g groupname
    
  4. Display detailed user quota with verbose output:

    quota -v
    
  5. Check inode usage for a user:

    quota -i username
    

Common Issues

  • Quotas not enabled: Users may encounter quotas not enabled errors if the filesystem does not have quotas enabled. Ensure quota support is enabled in the filesystem using quotaon.
  • Permission Denied: Non-root users can only check their own quota unless additional permissions are granted.

Integration

quota can be integrated with other commands for comprehensive disk management:

  • Monitoring Disk Space in a Script:

    #!/bin/bash
    LIMIT=50000
    CURRENT=$(quota -u | grep '/dev/sda1' | awk '{print $2}')
    if [ "$CURRENT" -gt "$LIMIT" ]; then
      echo "Warning: Disk usage is above the limit."
    fi
    
  • Combining with crontab for Regular Alerts:
    Add a cron job to notify when quotas are near the limit:

    0 * * * * /usr/local/bin/check_quota.sh
    
  • edquota: Edit user quotas.
  • repquota: Summarize quotas for a filesystem.
  • quotaon, quotaoff: Enable/disable disk quotas.

Further information can be found in the official documentation and detailed guidebooks often available online and in operating system documentation packages.