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.
The route
Jump straight to the step you need, or tick off Done means at the end.
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
- Replace ACCOUNT_NAME with the account you actually intend to edit.
- Check the version output matches the behaviour described here.
- Read the quota report. It may say the account has no quota, or show current usage and limits. If the target filesystem is not mounted with quotas, fix that separately first; do not expect
edquotato enable them for you.
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.
- Block limits are kibibyte blocks by default, where one block is 1024 bytes. Append uppercase
K,M,GorTfor kibibytes, mebibytes, gibibytes or tebibytes. - Inode limits are counts, not storage sizes: lowercase
k,m,gandtexpress powers of 1000 inodes. - Example: to let a user exceed 2 GiB temporarily but never write past 3 GiB, use values equivalent to
2Gand3Gin the block soft and hard columns. For 500,000 and 600,000 inodes, enter those literal counts. - Keep soft no higher than hard unless you have a specific, tested reason not to.
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
- Group and project quotas use
-gand-P, with the corresponding group or project name or numeric ID. - -F forces a format, and should only be used once you have identified the quota format and need to disable autodetection; supported names are
vfsold,vfsv0,vfsv1,rpcandxfs. - -r edits non-local quota use through
rpc.rquotad, but only works when these tools were built with RPC set-quota support. Do not add it to a local command. - -m changes NFSv4 pathname handling and can break quota over RPC with a newer
rpc.rquotad. Leave it out unless a legacy deployment specifically needs it.
Done means
- Confirmed quota support, the account and the target filesystem.
- Changed only soft and hard limits, using the correct block and inode units.
- Verified with quota -u ACCOUNT_NAME after saving.
- Recorded the old values and know how to restore them.
- Treated grace-period, group, project and remote options as separate administrative changes, not bundled into one edit.