quotacheck

systemLinux/Unix
The quotacheck command is one of the most frequently used commands in Linux/Unix-like operating systems. quotacheck Scan a filesystem for disk usage and create, check, or repair quota files

Quick Reference

Command Name:

quotacheck

Category:

system

Platform:

Linux/Unix

Basic Usage:

quotacheck [options] [arguments]

Common Use Cases

    Syntax

    quotacheck [options] [filesystem...]

    Options

    Option Description
    -a, --all Check all mounted filesystems with quotas
    -b, --backup Create backups of the old quota files
    -c, --create-files Create new quota files
    -d, --delete-files Delete old quota files first
    -f, --force Force check even if quotas are inconsistent
    -g, --group Check group quotas
    -m, --no-remount Do not remount the filesystem read-only
    -M, --try-remount Try to remount the filesystem read-only (deprecated)
    -R, --skip-scan Skip scanning the filesystem and use the current quota files
    -u, --user Check user quotas
    -v, --verbose Display more information during execution
    -F, --format=format Check quotas of a specific format (vfsold, vfsv0, vfsv1, etc.)
    -h, --help Display help message and exit
    -V, --version Display version information and exit

    Examples

    How to Use These Examples

    The examples below show common ways to use the quotacheck command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    sudo quotacheck -avug
    Scan all filesystems with quotas enabled, check both user and group quotas, and be verbose.
    sudo quotacheck -vum /home
    Check user quotas on the /home filesystem and display verbose output.
    # Advanced Examples Advanced
    sudo quotacheck -avugm Check all mounted filesystems with quotas, for both users and groups, with verbose output, and force check even if quotas are enabled. sudo quotacheck -c /dev/sda1 Create new quota files for the specified device. sudo quotacheck -f /home Force check of quotas on /home even if it has inconsistencies. sudo quotacheck -d /home Delete the old quota files before creating new ones. sudo quotacheck -R /home Skip scanning the filesystem and use the current quota files. sudo quotacheck -vugF vfsold /home Use the specified quota format (vfsold) for the operation.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `quotacheck` command is an essential system administration tool in Unix/Linux systems that scans filesystems to build or verify quota databases. These databases track disk usage per user and group, enabling the enforcement of storage limits through the quota system. When disk quotas are implemented on a system, the kernel needs to keep track of disk usage for each user and group. This information is stored in special files, typically named `aquota.user` and `aquota.group` (or older variants like `quota.user` and `quota.group`) located at the root of each filesystem with quotas enabled. The `quotacheck` command serves several critical functions: 1. Creation: It can create new quota database files when quotas are being set up for the first time on a filesystem. 2. Verification: It compares the actual disk usage (by scanning the filesystem) with the records in the quota database files to ensure consistency. 3. Repair: When discrepancies are found, `quotacheck` updates the quota database to reflect the actual usage, essentially repairing the quota accounting. 4. Maintenance: System administrators run it periodically (often via cron jobs) to ensure quota databases remain accurate. Running `quotacheck` is typically necessary in the following scenarios: - Initial quota setup on a filesystem - After an unclean system shutdown or filesystem corruption - After significant filesystem changes outside the quota system's tracking - Periodically as preventive maintenance - When migrating to a different quota format The command usually requires root privileges because it needs to access system-wide filesystem information and modify quota database files. It's commonly run with the `-avug` options to check all filesystems with quotas enabled (`-a`), in verbose mode (`-v`), for both users (`-u`) and groups (`-g`). Modern Linux kernels often use journaled quota formats that reduce the need for frequent quota checks, but `quotacheck` remains an important tool for initializing quota databases and handling recovery scenarios. It's an integral part of the Linux quota system along with related commands like `quota`, `edquota`, `repquota`, `quotaon`, and `quotaoff`. Before running `quotacheck`, it's generally recommended to temporarily disable quotas using `quotaoff` to prevent inconsistencies during the checking process, then re-enable them afterward with `quotaon`.

    Related Commands

    These commands are frequently used alongside quotacheck or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the quotacheck command works in different scenarios.

    $ quotacheck
    View All Commands