Get the units wrong with setquota and you can silently hand someone a 1 MiB quota instead of 1 GiB, so check every value before you press enter. You will set a user quota on an existing quota-enabled filesystem, check the result, and know how to revise or remove it. The examples use the installed quota 4.06 utilities. Allow about ten minutes for one user, plus time to check your change against the storage policy. You need root privileges, because only the super-user may edit quotas.
This guide assumes quota support and the quota files are already configured for the filesystem. setquota edits limits; it does not replace the earlier work of choosing a filesystem, preparing its quota data or enabling quota enforcement.
Confirm which binary and package version you are about to use. The version matters because quota utilities and filesystem formats can differ between releases:
$ command -v setquota
/usr/sbin/setquota
$ dpkg-query -W -f='${Package} ${Version}\n' quota
quota 4.06-1build6
$ setquota --version
Quota utilities version 4.06.
Choose the exact filesystem mountpoint, user and policy before using sudo. In the examples, /home is the filesystem and alice is the user. Check that the mountpoint is what you expect:
$ findmnt --target /home
$ getent passwd alice
Checkpoint: stop if /home is not the filesystem you intend to change, or if the account name resolves to a different person than expected.
The positional values are, in order, block soft limit, block hard limit, inode soft limit and inode hard limit. A block limit is measured in kibibyte blocks by default. The suffixes K, M, G and T mean kibibytes, mebibytes, gibibytes and tebibytes, so 1024M is 1 GiB, not 1,024 decimal megabytes.
Inode limits count files and directories rather than bytes. They are literal numbers unless a lower-case suffix is used: k, m, g and t scale by powers of 1,000. Keep the soft limit at or below the hard limit. A soft limit can be exceeded temporarily while its grace period runs; the hard limit is the firm ceiling enforced by the quota system.
For a policy allowing Alice 1 GiB soft and 1.5 GiB hard, with no inode limit, the values are:
block soft: 1024M
block hard: 1536M
inode soft: 0
inode hard: 0
A value of 0 disables that particular limit. Do not use zero as a placeholder unless unlimited usage is genuinely the policy you want.
The default quota type is user quota, so this command sets Alice's limits on /home:
$ sudo setquota -u alice 1024M 1536M 0 0 /home
A successful setquota normally produces no explanatory output. Check the exit status immediately if you are putting the command in a script:
$ printf 'setquota exit status: %s\n' "$?"
setquota exit status: 0
There is no separate save command. The command changes the quota data for the named filesystem, which is why the filesystem argument deserves an explicit review before pressing Enter. Do not use -a casually: --all applies the setting to every filesystem with quota in /etc/mtab.
Verify the stored limits with the quota reporting tool:
$ sudo quota -u alice
The exact columns and formatting depend on the filesystem and local quota configuration. Look for Alice's entry on /home and confirm the soft and hard block limits match the policy. If you also set inode limits, check those columns separately.
Checkpoint: do not proceed to a group or project quota until the user entry and target filesystem are correct.
Use -g for a group and -P for a project. The name position then means a group name or project name, and a numeric name is treated as an ID unless you use the name-resolution option described in the manual.
$ sudo setquota -g developers 5120M 6144M 0 0 /home
$ sudo setquota -P build-area 2048M 3072M 0 0 /srv
These examples change two different quota namespaces. They do not change every member's individual user quota. Verify each namespace with the reporting commands and local project-quota tooling before allowing a workload to rely on it.
Grace periods are separate from the limits. Use -t to set the default block and inode grace periods for users, groups or projects; the values are seconds:
$ sudo setquota -u -t 604800 604800 /home
This sets both default grace periods to seven days for the specified filesystem. The command affects the selected quota type, so include -g or -P when that is the policy you are changing. For one named account's current grace timers, use -T and provide the name:
$ sudo setquota -u -T alice 604800 604800 /home
Use the literal value unset when you need to clear an individual grace timer, where supported by the installed utility. Do not confuse a grace period with permission to exceed the hard limit: it only governs enforcement of a soft limit.
For several entries, --batch reads lines in the same five-field order as the command line: name, block soft limit, block hard limit, inode soft limit and inode hard limit. Empty lines and lines beginning with # are ignored.
$ cat quota-users.txt
# name block-soft block-hard inode-soft inode-hard
alice 1024M 1536M 0 0
bob 2048M 3072M 50000 60000
$ sudo setquota -u -b /home < quota-users.txt
Review the file before running it. Redirection feeds it to setquota: it does not make a backup and it does not ask for confirmation. By default, a malformed line can stop batch processing. The --continue-batch option continues with later lines after a parsing failure, but that can leave a partly applied file, so inspect the result rather than assuming every row succeeded.
To undo a mistaken limit, run setquota again with the correct values. To remove only a block or inode restriction, set that pair to 0. Keep a copy of the intended policy and verify the resulting entry: there is no general interactive undo command.
1024 when you meant 1 GiB sets 1,024 KiB instead, because block values are kibibyte blocks. Prefer a visible suffix such as 1024M.M for inodes applies the block-unit convention to the wrong field. Inode suffixes are lower-case and decimal; plain numbers are easiest to audit.-g or -P edits a user quota instead, because user mode is the default.-a, invoke it once for each filesystem you intend to change.getent and use the installed command's name-resolution option only when that distinction is intentional.If the command reports a format, permission or filesystem error, do not keep retrying with broader privileges. Check the filesystem has the relevant quota format and that quota administration is configured for it. A failed command should leave you with an error to investigate; a successful command still needs the reporting check above.
setquota again, and have not used --all accidentally.