Set Linux User Quotas Safely with edquota

Get a user's disk quota wrong and you either lock them out early or let them fill the disk anyway, so edquota deserves a careful pass. The examples use quota utilities 4.06, installed here as package version 4.06-1build6. Only the super-user may edit quotas.

Allow about fifteen minutes for one user if quotas are already enabled on the target filesystem. You need a root shell through sudo, an existing user, and a filesystem with quota support. This changes limits that can affect writes by the account, so keep a second administrator session open and record the old values before saving.

1. Confirm the installed command and quota state

Start with read-only checks. Neither edits a quota:

$ edquota --version
Quota utilities version 4.06.
$ quota -u ACCOUNT_NAME

Checkpoint: write down the account name, its current limits, and the filesystem you mean to change. The -f option restricts an operation to one filesystem; leave it out and edquota touches every filesystem with quotas.

2. Open one user's quota record

Run the editor as root. This example deliberately strips VISUAL from the environment so the chosen editor is unambiguous. Replace ACCOUNT_NAME and /MOUNTPOINT with real values:

$ sudo env -u VISUAL EDITOR=vi edquota -u -f /MOUNTPOINT ACCOUNT_NAME

-u selects a user quota and is also the default. Use a filesystem mountpoint such as /home, not a quota file path. The editor receives a temporary ASCII representation with a heading and columns for filesystem, blocks, block soft limit, block hard limit, inodes, inode soft limit and inode hard limit:

Disk quotas for user ACCOUNT_NAME (uid 1004):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/DEVICE                  123456       200000     250000   1200       5000     6000

The exact device name, usage and identity values vary by host. Current blocks and inodes are informational only. Only the soft and hard limits are editable, so do not try to correct the usage columns in this file.

3. Set limits using the correct units

Change only the soft and hard columns for the filesystem you selected.

A value of zero means no quota is imposed for that limit; it is not the same as zero usage. Do not enter zero as a shortcut unless lifting that restriction is genuinely what you mean to do.

Save and quit your editor. On leaving, edquota reads the temporary file and writes the binary quota data. Opened the wrong account or filesystem? Quit without saving. Saved an unwanted change? Run the command again and re-enter the recorded values; there is no general undo command.

4. Verify the resulting limits

Ask the quota reporter to display the account once edquota exits:

$ quota -u ACCOUNT_NAME

Check the filesystem row itself, not just the command's exit status. Reported units and formatting differ between quota formats, but the soft and hard limits should match what you entered. If you named a filesystem with -f, confirm the changed row is the one you meant.

Checkpoint: run the same command from a separate session, or have the account owner retry the write that was previously failing. A soft limit only permits excess usage for its grace period; once that expires, the soft limit is enforced as a hard one. A successful edit does not mean an already over-limit account can keep writing indefinitely.

5. Copy a prototype to several users

For a group of users who should start with identical limits, use one existing user as the prototype:

$ sudo env -u VISUAL EDITOR=vi edquota -p PROTOTYPE_ACCOUNT -u USER_ONE USER_TWO

-p duplicates the prototype user's quotas for each named user. Read the command carefully: a numeric argument is treated as a UID by default, not as a username that happens to be all digits. --always-resolve tells edquota to attempt name-to-ID resolution even for digit-only names.

This is a state-changing batch operation. Capture the target list and verify each result with quota -u USER_ONE and quota -u USER_TWO. Wrong limits copied? Rerun ordinary editing for each affected user and restore the intended values.

6. Edit grace periods only when required

Quota limits and grace periods are separate things. To edit the soft time limits for each filesystem:

$ sudo env -u VISUAL EDITOR=vi edquota -t

Time values can use seconds, minutes, hours or days. Old quota formats fall back to kernel defaults when time limits are zero; newer formats require explicit time limits. Treat a change here as a policy change for every relevant filesystem, not a repair for one user's record.

To edit the time at which a particular user's soft limit gets enforced, add -T with the account name:

$ sudo env -u VISUAL EDITOR=vi edquota -T -u ACCOUNT_NAME

The value is either unset or a number with one of the same time units. Check the resulting quota report and note the old value before changing it.

Common traps

Done means