LPI Linux Certification in a Nutshell (29 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
4.39Mb size Format: txt, pdf, ePub
Name

quota

Syntax
quota [-u] [
options
]
user
quota -g [
options
]
group
Description

Displays quota limits on
user
or
group
. The
-u
option
is the default. Only the superuser may use the
-u
flag and
user
to
view the limits of other users. Other users can use the
-g
flag and
group
to
view only the limits of groups of which they are members, provided
that the
quota.group
files are readable by
them.

Frequently used options
-q

Sets quiet mode, which shows only over-quota
situations.

-v

Enables verbose mode to display quotas even if no
storage space is allocated.

Example 1

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.

Example 2

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.

Name

quotaon

Syntax
quotaon [
options
] [
filesystems
]
quotaon [
options
] -a
Description

Enable previously configured disk quotas on one or
more
filesystems
.

Frequently used options
-a

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.

-g

Turns on group quotas. This option is not necessary when
using the
-a
option, which includes both
user and group quotas.

-u

Turns on user quotas; this is the default.

-v

Enables verbose mode to display a message for each
filesystem where quotas are turned on.

Example 1

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
Example 2

Turn on user quotas only on the
/home
filesystem:

#
quotaon -gv /home
/dev/sda9: group quotas turned on
Name

quotaoff

Syntax
quotaoff [
options
] [
filesystems
]
quotaoff [
options
] -a
Description

Disables disk quotas on one or more
filesystems
.

Frequently used options
-a

Turns quotas off for all filesystems in
/etc/fstab
.

-g

Turns off group quotas. This option is not necessary
when using the
-a
option, which includes
both user and group quotas.

-u

Turns off user quotas; this is the default.

-v

Enables verbose mode to display a message for each
filesystem where quotas are turned off.

Example

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
Name

quotacheck

Syntax
quotacheck [
options
]
filesystems
quotacheck [
options
] -a
Description

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
.

Frequently used options
-a

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.

-g
group

Compiles information only on
group
.

-u
user

Compiles information only on
user
; 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.

-v

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.

Example 1

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.

Example 2

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
Name

edquota

Syntax
edquota [-p
proto-user
] [
options
]
names
edquota [
options
] -t
Description

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 the
EDITOR
or
VISUAL
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 in
names
is modified. If
proto-user
is specified with the
-p
option, quotas of that user or group are
copied and used for
names
and no editor
is launched. In the second form with the
-t
option, the soft limit settings are edited interactively for each
filesystem.

Frequently used options
-g

Modify group quotas. If
-g
is
specified, all
names
are assumed to
be groups and not users, even if
-u
is
also specified.

-p
proto-user

Duplicate the quotas of the prototypical user or group
proto-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.

-t

Modify soft limits. Time units of
sec
(onds),
min
(utes),
hour
(s),
day
(s),
week
(s), and
month
(s) are understood.

-u

Modify user quotas. This is the default action. This
option is ignored if
-g
is also
specified.

Note

The following examples use the
vi
editor. The contents of the edit buffer, not program output, are
shown after each example.

Example 1

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
.

Example 2

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).

Name

repquota

Syntax
repquota [
options
]
filesystems
repquota -a [
options
]
Description

Used to report on the status of quotas. In the first
form,
repquota
displays a summary
report on the quotas for the given
filesystems
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
.

Frequently used options
-a

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.

-g

Report quotas for groups.

-u

Report quotas for users; this is the default
action.

-v

Enable verbose mode, which adds a descriptive header to
the output.

Example

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

Other books

Cain by Kathi S Barton
Chasing Ghosts by Lee Driver
Foster by Claire Keegan
Every Third Thought by John Barth
Bound by Time by A.D. Trosper
Apocalypse by Nancy Springer
Heaven Should Fall by Rebecca Coleman
Old Sinners Never Die by Dorothy Salisbury Davis