Read LPI Linux Certification in a Nutshell Online
Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger
Tags: #Reference:Computers
quota
quota [-u] [options
]user
quota -g [options
]group
Displays quota limits onuser
orgroup
. The
-u
option
is the default. Only the superuser may use the
-u
flag anduser
to
view the limits of other users. Other users can use the
-g
flag andgroup
to
view only the limits of groups of which they are members, provided
that the
quota.group
files are readable by
them.
Sets quiet mode, which shows only over-quota
situations.
Enables verbose mode to display quotas even if no
storage space is allocated.
As
root
, examine all quotas for user
jdoe
:
#quota -uv jdoe
Disk quotas for user jdoe (uid 500):
Filesystem blks quota limit grace files quota limit grace
/dev/sda9 9456 10000 10200 32 0 0
/dev/hda1 23 0 0 17 0 0
This example shows that
jdoe
is barely
within her soft limit of 10,000 blocks, with a corresponding hard
limit of 10,200 blocks on
/dev/sda9
, and has no
quota on
/dev/hda1
. The entry for
/dev/hda1
is displayed in response to the
-v
option. No values are shown for the grace
periods, because the soft limit has not been exceeded.
As user
jdoe
, examine quotas for the
finance
group, of which he is a member:
$quota -gv finance
Disk quotas for group finance (gid 501):
Filesystem blks quota limit grace files quota limit grace
/dev/sda9 1000* 990 1000 6days 34 3980 4000
/dev/hda1 0 0 0 0 0 0
Here, the
finance
group has exceeded its
meager soft limit of 990 blocks and has come up against its hard
limit of 1,000 blocks. (The write operation that wrote the 1,000th
block was probably incomplete.) The original grace period in this
example was set to seven days and has six days remaining, meaning
that one day has elapsed since the soft limit was exceeded.
quotaon
quotaon [options
] [filesystems
]
quotaon [options
] -a
Enable previously configured disk quotas on one or
morefilesystems
.
Turns quotas on for all filesystems in
/etc/fstab
that are marked read-write
with quotas. This is normally used automatically at boot time
to enable quotas.
Turns on group quotas. This option is not necessary when
using the
-a
option, which includes both
user and group quotas.
Turns on user quotas; this is the default.
Enables verbose mode to display a message for each
filesystem where quotas are turned on.
Turn on all quotas as defined in
/etc/fstab
:
#quotaon -av
/dev/sda9: group quotas turned on
/dev/sda9: user quotas turned on
/dev/hda1: group quotas turned on
/dev/hda1: user quotas turned on
Turn on user quotas only on the
/home
filesystem:
#quotaon -gv /home
/dev/sda9: group quotas turned on
quotaoff
quotaoff [options
] [filesystems
]
quotaoff [options
] -a
Disables disk quotas on one or morefilesystems
.
Turns quotas off for all filesystems in
/etc/fstab
.
Turns off group quotas. This option is not necessary
when using the
-a
option, which includes
both user and group quotas.
Turns off user quotas; this is the default.
Enables verbose mode to display a message for each
filesystem where quotas are turned off.
Turn off all quotas:
#quotaoff -av
/dev/sda9: group quotas turned off
/dev/sda9: user quotas turned off
/dev/hda1: group quotas turned off
/dev/hda1: user quotas turned off
quotacheck
quotacheck [options
]filesystems
quotacheck [options
] -a
Examine filesystems and compile quota databases. This
command is not specifically called out in the LPI Objectives for
Exam 101, but is an important component of the Linux quota system.
You should run the
quotacheck -a
command on a
regular basis (perhaps weekly) via
cron
.
Checks all of the quotas for the filesystems mentioned
in
/etc/fstab
. Both user and group quotas
are checked as indicated by the
usrquota
and
grpquota
options.
group
Compiles information only ongroup
.
user
Compiles information only onuser
; this is the default action.
However, if the
-g
option is specified,
then this option also should be specified when both group and
user quotas are to be processed.
Enables verbose mode to display information about what
the program is doing. This option shows activity by displaying
a spinning character in the terminal. This is nice but could
be a problem if you are logged in over a slow modem
link.
Initialize all quota files:
#quotaoff -a
#quotacheck -aguv
Scanning /dev/sda9 [/home] done
Checked 237 directories and 714 files
Using quotafile /home/quota.user
Using quotafile /home/quota.group
Scanning /dev/hda1 [/mnt/hd] done
Checked 3534 directories and 72673 files
Using quotafile /mnt/hd/quota.user
Using quotafile /mnt/hd/quota.group
#quotaon -a
By turning off quotas during the update, the quota database
files are updated.
With quotas active, update the user quotas in memory for
/home
:
#quotacheck -v /home
Scanning /dev/sda9 [/home] done
Checked 237 directories and 714 files
Using quotafile /home/quota.user
Updating in-core user quotas
edquota
edquota [-pproto-user
] [options
]names
edquota [options
] -t
Modify user or group quotas. This interactive command
uses a text editor to configure quota parameters for users or
groups. The
vi
editor is used by default unless
either theEDITOR
orVISUAL
environment variables are set to
another editor, such as
emacs
. When the command
is issued, the editor is launched with a temporary file containing
quota settings. When the temporary file is saved and the editor is
terminated, the changes are saved in the quota databases.
In the first form, a space-separated list of users or groups
specified innames
is modified. Ifproto-user
is specified with the
-p
option, quotas of that user or group are
copied and used fornames
and no editor
is launched. In the second form with the
-t
option, the soft limit settings are edited interactively for each
filesystem.
Modify group quotas. If
-g
is
specified, allnames
are assumed to
be groups and not users, even if
-u
is
also specified.
proto-user
Duplicate the quotas of the prototypical user or groupproto-user
for each user or group
specified. This is the normal mechanism used to initialize
quotas for multiple users or groups at the same time.
Modify soft limits. Time units ofsec
(onds),min
(utes),hour
(s),day
(s),week
(s), andmonth
(s) are understood.
Modify user quotas. This is the default action. This
option is ignored if
-g
is also
specified.
The following examples use the
vi
editor. The contents of the edit buffer, not program output, are
shown after each example.
Modify the user quotas for
jdoe
:
#edquota -u jdoe
Quotas for user jdoe:
/dev/sda9: blocks in use: 87, limits (soft = 99900, hard = 100000)
inodes in use: 84, limits (soft = 0, hard = 0)
/dev/hda1: blocks in use: 0, limits (soft = 0, hard = 0)
inodes in use: 0, limits (soft = 0, hard = 0)
~
~
"/tmp/EdP.auHTZJ0" 5 lines, 241 characters
Here,
jdoe
has been allocated a soft
limit of 99,900 blocks (which on a default Linux
ext2
or
ext3
filesystem
with a 4k block size means 390 MB), a hard limit of 100,000 blocks
(only 400 KB higher than the soft limit), and no limit on the number
of files on
/dev/sda9
. She has no limits on
/dev/hda1
.
Modify soft limits for users on all filesystems:
#edquota -tu
Time units may be: days, hours, minutes, or seconds
Grace period before enforcing soft limits for users:
/dev/sda9: block grace period: 7 days,
file grace period: 3 days
/dev/hda1: block grace period: 7 days,
file grace period: 3 days
~
~
"/tmp/EdP.aiTShJB" 5 lines, 249 characters
Here, the user grace periods have been set to seven days for
blocks (disk space) and three days for files (inodes).
repquota
repquota [options
]filesystems
repquota -a [options
]
Used to report on the status of quotas. In the first
form,repquota
displays a summary
report on the quotas for the givenfilesystems
on a per-user or per-group
basis. In the second form, the
-a
option causes
a summary for all filesystems with quotas to be displayed. This
command fails for nonroot users unless the quota database files are
world-readable. The current number of files and the amount of space
utilized are printed for each user, along with any quotas created
with
edquota
.
Report on all of the quotas for the read-write
filesystems mentioned in
/etc/fstab
. Both
user and group quotas are reported as indicated by the
usrquota
and
grpquota
options.
Report quotas for groups.
Report quotas for users; this is the default
action.
Enable verbose mode, which adds a descriptive header to
the output.
Report user quotas for
/home
:
#repquota -v /home
*** Report for user quotas on /dev/sda9 (/home)
Block limits File limits
User used soft hard grace used soft hard grace
root -- 418941 0 0 269 0 0
328 -- 1411 0 0 20 0 0
jdean -- 9818 99900 100000 334 0 0
u1 -- 44 0 0 43 0 0
u2 -- 44 0 0 43 0 0
u3 -- 127 155 300 124 0 0
jdoe -- 87 99900 100000 84 0 0
bsmith -- 42 1990 2000 41 0 0