LPI Linux Certification in a Nutshell (40 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
2.06Mb size Format: txt, pdf, ePub
Devices, Linux Filesystems, and the Filesystem Hierarchy
Standard
Objective 104.1: Create Partitions and Filesystems
Disk drives and partitions
  • IDE disks are known as
    /dev/hda
    ,
    /dev/hdb
    ,
    /dev/hdc
    ,
    /dev/hdd
    , and
    so on.

  • Any disks using the SCSI emulation layer are known as
    /dev/sda
    ,
    /dev/sdb
    ,
    /dev/sdc
    , and so on. These include SCSI
    disks, SATA disks, and, in newer kernels, IDE disks.

  • Three types of partitions:

    Primary

    Filesystem container. At least one must exist, and up
    to four can exist on a single physical disk. They are
    identified with numbers 1 to 4, such as
    /dev/hda1
    ,
    /dev/hda2
    , and so on.

    Extended

    A variant of a primary partition, but it
    cannot contain a filesystem. Instead, it contains one or
    more
    logical partitions
    . Only one
    extended partition may exist, and it takes one of the four
    possible spots for primary partitions.

    Logical

    Created
    within
    the
    extended partition. From 1 to 12 logical partitions may be
    created. They are numbered from 5 to 16, such as
    /dev/hda5
    ,
    /dev/hda6
    , and so on.

  • Up to 15 partitions with filesystems may exist on a single
    physical disk.

Filesystems
  • The Linux kernel supports many different kinds of
    filesystems:

    ext3

    The third extended filesystem. A journaling
    filesystem, this has been the default for most Linux
    distributions since the early 2000s.

    ext2

    The second extended filesystem. This was the initial
    default Linux filesystem.
    ext3
    is
    basically
    ext2
    with journaling
    support.

    xfs

    Journaling filesystem created by Silicon Graphics for
    IRIX and ported to Linux.

    reiserfs

    This was the first journaling filesystem introduced in
    the standard Linux kernel.

    vfat

    A Microsoft Windows filesystem for Windows 95, 98, and
    ME systems.

The root filesystem and mount points
  • The top of the filesystem tree is occupied by the
    root filesystem
    . Other filesystems are
    mounted under it, creating a unified filesystem.

  • /etc
    ,
    /lib
    ,
    /bin
    ,
    /sbin
    , and
    /dev
    must be part of the root
    filesystem.

Partition and filesystem management commands

The following commands are commonly used to repair and manage
filesystems:

fdisk
[
device]

Manipulate or display the partition table for
device
using a command-driven
interactive text interface.
device
is
a physical disk such as
/dev/hda
, not a
partition such as
/dev/hda1
.

mkfs
device

Make a filesystem on
device
,
which must be a partition.

mkswap
device

Prepare a partition for use as swap space.

Objective 104.2: Maintain the Integrity of Filesystems
Filesystem commands
df
[
directories
]

Display overall disk utilization information for
mounted filesystems on
directories
.

du
[
directories
]

Display disk utilization information for
directories
.

fsck
filesystems

Check
filesystems
for errors
and optionally correct them.

dumpe2fs
filesystem

Display the detailed information about the
ext2
or
ext3
filesystem at
filesystem
.

tune2fs
filesystem

Modify filesystem variables for the
ext2
or
ext3
filesystem at
filesystem
.

Objective 104.3: Control Filesystem Mounting and
Unmounting
Managing the filesystem table
  • /etc/fstab
    contains mount
    information for filesystems. Each line contains a single
    filesystem entry made up of six fields, shown in
    Table 10-11
    .

  • The
    /media
    directory is often used by
    distributions as a place to automount hotplug devices, such as USB
    drives.

    Table 10-11. Fields found in the /etc/fstab file

    Entry

    Description

    Device

    The device file for the
    partition holding the filesystem.

    Mount point

    The directory upon which the
    filesystem is to be mounted.

    Filesystem type

    A filesystem type, such as
    ext3
    .

    Mount options

    A comma-separated
    list.

    Dump frequency

    For use with
    dump
    .

    Pass number for
    fsck

    Used at boot
    time.

Mounting and unmounting

The following commands are used to mount and unmount
filesystems:

mount
device
mount
directory
mount
device
directory

Mount filesystems onto the hierarchy. The first and second
forms consult
/etc/fstab
for additional
information.

umount
device
umount
directory

Unmount the filesystem on
device
or mount it on
directory
.

Filesystem types

Common filesystem types compatible with Linux include:

ext2

The standard Linux filesystem.

ext3

A journaling filesystem that is backward-compatible with
ext2
.

iso9660

The standard CD-ROM format.

vfat

The Microsoft Windows FAT filesystem.

nfs

Remote servers.

proc

A system abstraction for access to kernel
parameters.

swap

Swap partitions.

Objective 104.4: Set and View Disk Quotas
Quota types
Per-user hard

The maximum size for an individual.

Per-user soft

A warning threshold.

Per-group hard

The maximum size for a group.

Per-group soft

A warning threshold.

Grace period

A time restriction on the soft limit.

Commands
quota
user
quota -g
group

Display quota limits on
user
or
group
.

quotaon
[
filesystems
]

Enable previously configured disk quotas on one or more
filesystems
.

quotaoff
[
filesystems
]

Disable disk quotas on one or more
filesystems
.

quotacheck
[
filesystems
]

Examine filesystems and compile quota databases. Usually
run via
cron
.

edquota
names

Modify user or group quotas by spawning a text
editor.

repquota
filesystems

Display a summary report of quota status for
filesystems
, or use
-a
for all
file
systems.

Note

Enabling quotas requires
usrquota
and/or
grpquota
options in
/etc/fstab
, creation of
quota.user
and
quota.group
files at the top of the filesystem, a
quotacheck
, and a
quotaon
.

Objective 104.5: Manage File Permissions and Ownership
Access control
  • Access control is implemented using a set of
    properties called the
    access mode
    , stored in
    the inode. Three classes of user are defined:

    User

    The user who owns the file.

    Group

    The group that owns the file.

    Other

    All other users on the system.

  • Three permissions are either granted or not granted to each
    class of user:

    Read (
    r
    )

    Allows access to file contents and listing of
    directory contents.

    Write (
    w
    )

    Allows writing a file or creating files in a
    directory.

    Execute (
    x
    )

    Allows execution of a file and ability to read/write
    files in a directory.

  • These comprise nine bits in the mode User
    rwx
    , Group
    rwx
    , and Other
    rwx
    .

  • Three additional mode bits are defined:

    SUID

    To grant processes the rights of an executable file’s
    owner.

    SGID

    To grant processes the rights of an executable file’s
    group.

    Sticky bit

    Prohibits file deletion by nonowners.

  • These 12-mode bits are often referred to in octal notation
    as well as with mnemonic constructs.

  • Mode bits are displayed using such commands as
    ls
    and
    stat
    .

Setting access modes
  • New files receive initial access mode as described by the
    umask
    .

  • The
    umask
    strips specified bits from
    the initial mode settings. Typical umasks are 002 and 022.

  • Existing file modes are changed using
    chmod
    with either symbolic or octal mode
    specifications:

    • Symbolic:

      [ugoa][-+=][rwxXst]
    • Octal bits:

      user r, w, x, group r, w, x, other r, w, x
      rwxrwxrwx = 111111111 = 777
      rwxr-xr-- = 111101100 = 751

chmod
uses the following
syntax:

chmod
mode
files

Modify the access mode on
files
using a symbolic or octal
mode
.

Commands for file ownership
chown
user-owner
.
group-owner
files

Change the owner and/or group of
files
to
user-owner
and/or
group-owner
.

chgrp
group-owner
files

Change the group ownership of
files
to
group-owner
.

chgrp
functionality is included in
chown
.

Other books

Swarm (Dead Ends) by G.D. Lang
Scorecasting by Tobias Moskowitz
Taming The Biker - A MC Biker Romantic Suspense Story by Alexandra, Cassie, Middleton, K.L.
Augusta Played by Kelly Cherry
The Bull Rider's Twins by Tina Leonard