This question was spawned originally by problems with version 3.13 of the quota
command, which is essentially useless as a tool for the end user to determine quota information. For example, if alice
runs quota
, she might see output like this:
Disk quotas for user alice (uid 100):
Filesystem blocks quota limit grace files quota limit grace
fileserver.example.com:/staff/b/bob
9254720 9728000 10240000 119768 0 0
Alice would rightly wonder what this had to do with her account.
It turns out that the minds behind the quota-utils
package at long last realized the problems inherent in the tool; with version 4.00 (available in Fedora 16) there are several new options available that turn the quota
command into something that actually produces useful information.
Of particular interest is the -f
option:
-f, --filesystem-list display quota information only for given filesystems
So now, a user can run:
quota -f ~
And get the quota information for their home directory. Additionally, the -s
option will display "human readable" numbers instead of displaying everything as blocks.
For Alice, this might look like:
$ quota -s -f ~
Disk quotas for user alice (uid 100):
Filesystem blocks quota limit grace files quota limit grace
fileserver.example.com:/staff/a/alice
9038M 9500M 10000M 120k 0 0
Additionally, there are two options that make it much easier to process the output from quota
in a script:
- The
-w
option inhibits the line wrapping when the "filesystem" name is too long.
- The
-p
option displays 0
for the grace time if the user is not in an over-quota situation. This means that there are always the same number of fields (whereas with the previous version of quota
the number of fields could vary depending on the situation).
Combining all of the above, we get something like this:
$ quota -wp -f ~
Disk quotas for user alice (uid 100):
Filesystem space quota limit grace files quota limit grace
fileserver.example.com:/staff/a/alice 9254720 9728000 10240000 0 119768 0
Which is much more useful for automation.