Sie sind auf Seite 1von 574

Linux+ Guide to Linux

Certification, Second Edition

Chapter 1
Introduction to Linux
Objectives

• Understand the purpose of an operating system


• Outline the key features of the Linux operating
system
• Describe the origins of the Linux operating system
• Identify the characteristics of various Linux
distributions and where to find them
• Explain the common uses of Linux in industry today

Linux+ Guide to Linux Certification, 2e 2


Operating Systems

• Computers have two fundamental components:


– Hardware: Physical components inside a computer
– Software: Set of instructions or programs that
understand how to use the hardware of the
computer in a meaningful way

Linux+ Guide to Linux Certification, 2e 3


Operating Systems (continued)

• Hardware components include:


– Processor (CPU)
– Physical memory (RAM)
– Hard disk, floppy disk, and CD-ROM drives
– Sound and video cards
– Circuit boards

Linux+ Guide to Linux Certification, 2e 4


Operating Systems (continued)

• Two different types of programs are executed on a


computer:
– Applications
– Operating system (OS) software
• Device Driver: Software containing instructions that
the OS uses to control and interact with a specific
type of computer hardware
• User Interface: An application program that allows
the user to interact with the OS and other
application programs

Linux+ Guide to Linux Certification, 2e 5


Operating Systems (continued)

Figure 1-1: The role of operating system software

Linux+ Guide to Linux Certification, 2e 6


Operating Systems (continued)

• Graphical user interface (GUI): Component of an


OS that provides a user-friendly interface
• System services: Applications that handle system-
related tasks
– Printing
– Scheduling programs
– Network access

Linux+ Guide to Linux Certification, 2e 7


Operating Systems (continued)

Figure 1-2: A Linux graphical user interface


Linux+ Guide to Linux Certification, 2e 8
The Linux Operating System

• OS used to run a variety of applications on a


variety of different hardware
• Has the ability to manage thousands of tasks at the
same time
• Allows multiple users to access the system
simultaneously
– Multiuser and multitasking OS

Linux+ Guide to Linux Certification, 2e 9


Versions of the
Linux Operating System

• Core component is called the Linux kernel


– Written almost entirely in the C programming
language
• Software can be used to modify appearance of
Linux, but the kernel is common to all Linux

Linux+ Guide to Linux Certification, 2e 10


Identifying Kernel Versions

• Linux kernel versions are composed of:


– Major number
– Minor number
• If odd, referred to as a developmental kernel
• If even, referred to as a production kernel
– Revision number

Linux+ Guide to Linux Certification, 2e 11


Identifying Kernel Versions (continued)

Table 1-1: Latest revisions of common Linux kernels

Linux+ Guide to Linux Certification, 2e 12


Licensing Linux

• Open Source Software (OSS): Programs


distributed and licensed so that the source code is
available to anyone who wants to examine, utilize,
or improve upon it
– Format and structure of source code follows rules
defined by the programming language in which it
was written

Linux+ Guide to Linux Certification, 2e 13


Licensing Linux (continued)

• Implications of OSS:
– Developed very rapidly through widespread
collaboration
– Bugs (errors) are noted and promptly fixed
– Features evolve quickly based on users’ needs
– Perceived value of the software increases because it
is based on usefulness, not on price

Linux+ Guide to Linux Certification, 2e 14


Licensing Linux (continued)

Table 1-2: Software types

Linux+ Guide to Linux Certification, 2e 15


Types of Open Source Licenses

• GNU Public License (GPL): Stipulates that the


source code of any software published under its
license must be freely available
• Artistic license: OSS license allowing source code
to be distributed freely, charged only at discretion
of original author

Linux+ Guide to Linux Certification, 2e 16


Types of Closed Source Licenses

• Most closed source software is sold commercially


– e.g., Microsoft or Electronic Arts software
• Freeware: Distributed free of charge; source code
is not available
• Shareware: Initially free, but requires payment after
a period of time or usage

Linux+ Guide to Linux Certification, 2e 17


Linux Advantages:
Risk Reduction

• Changes in the market or customer needs may


cause companies to change software frequently
– Can be costly and time-consuming
• Support for closed source software may end
– Vendor may go out of business
– Software version may be retired
• OSS products offer the opportunity to maintain and
change the source code

Linux+ Guide to Linux Certification, 2e 18


Linux Advantages:
Meeting Business Needs

• Common software available for Linux includes:


– Scientific and engineering software
– Software emulators
– Web servers, Web browsers, and e-commerce
suites
– Desktop productivity software
– Graphics manipulation software
– Database software
– Security software

Linux+ Guide to Linux Certification, 2e 19


Linux Advantages:
Stability and Security

• Customers using a closed source OS must rely on


the OS vendor to fix any bugs
– Waiting for a hot fix may take weeks or months
• Bugs and security loopholes in OSS programs can
be identified and fixed quickly
– Code is freely available and scrutinized by many
developers

Linux+ Guide to Linux Certification, 2e 20


Linux Advantages: Flexibility for
Different Hardware Platforms

• Partial list of hardware platforms on which Linux


can run:
– Intel – M68K
– Itanium – PA-RISC
– Mainframe (S/390) – SPARC
– Cirrus Logic ARM – Ultra-SPARC
– DEC Alpha – PowerPC (Macintosh)
– MIPS

Linux+ Guide to Linux Certification, 2e 21


Linux Advantages:
Ease of Customization
• Ability to control the inner workings of an OS
– To use Linux as an Internet Web server, compile the
kernel to include only the support needed to be an
Internet Web server
• Results in a much smaller and faster kernel

Linux+ Guide to Linux Certification, 2e 22


Linux Advantages:
Ease of Obtaining Support

• Linux documentation can be found on the Internet


– Frequently Asked Questions (FAQs)
– HOWTO documents
• Linux Newsgroups
• Linux User Group (LUG): Open forum of Linux
users who discuss and assist each other in using
and modifying the Linux OS

Linux+ Guide to Linux Certification, 2e 23


Linux Advantages:
Cost Reduction

Table 1-3: Calculating the total cost of ownership

Linux+ Guide to Linux Certification, 2e 24


The History of Linux

Figure 1-4: Timeline of UNIX and Linux development

Linux+ Guide to Linux Certification, 2e 25


UNIX

• Evolved from Multiplexed Information and


Computing Service (MULTICS)
• The first true multitasking, multiuser OS
• Written in the C programming language
– Portable OS
• OS from which Linux originated

Linux+ Guide to Linux Certification, 2e 26


UNIX (continued)

• Berkeley Software Distribution (BSD)


– Version of the original UNIX source code
• Common flavors of UNIX today include:
– Sun Microsystems’s Solaris
– Hewlett-Packard’s HP-UX
– IBM’s AIX UNIX

Linux+ Guide to Linux Certification, 2e 27


The Hacker Culture

• Hacker: Someone wanting to expand their


computing knowledge through experimentation
• Cracker: Someone who illegally uses computers for
personal benefit or to cause damage
• GNU Project: Free OS project started by Richard
Stallman

Linux+ Guide to Linux Certification, 2e 28


Linux

• First developed by Linus Torvalds in 1991


– Published under the GNU license
• Linux kernel developed collaboratively and
centrally managed
– Linux is simply a by-product of OSS development

Linux+ Guide to Linux Certification, 2e 29


Linux Distributions

• Red Hat and SuSE


• Distributions may appear different on the surface,
but run the same kernel
• Most distributions ship with a GUI that can be
further customized to suit needs of the user
– Core component of this GUI is X Windows

Linux+ Guide to Linux Certification, 2e 30


Linux Distributions (continued)

• GUI environment: X Windows in combination with a


window manager and desktop environment
• Two competing GUI environments in Linux:
– GNU Object Model Environment (GNOME)
– Kommon Desktop Environment (KDE)

Linux+ Guide to Linux Certification, 2e 31


Linux Distributions (continued)

Figure 1-5: The GNOME Desktop

Linux+ Guide to Linux Certification, 2e 32


Linux Distributions (continued)

• Package manager: Software system that installs


and maintains software
• Tarball: Compressed archive of files containing
scripts that install software to the correct location
on the system

Linux+ Guide to Linux Certification, 2e 33


Linux Distributions (continued)

Table 1-4: Common Linux distributions


Linux+ Guide to Linux Certification, 2e 34
Linux Distributions (continued)

Table 1-4 (continued): Common Linux distributions

Linux+ Guide to Linux Certification, 2e 35


Common Uses of Linux

• May be customized to provide services for a variety


of companies in a variety of situations
• Workstation services: Services used on a local
computer
• Server services: Services made available for other
computers across a network

Linux+ Guide to Linux Certification, 2e 36


Internet Servers: Mail Services

• Mail transfer agent (MTA): An e-mail server


• Mail delivery agent (MDA): Service that downloads
e-mail from an MTA
• Mail user agent (MUA): Program that allows e-mail
to be read by a user

Linux+ Guide to Linux Certification, 2e 37


Internet Servers:
Routing and FTP Services

• Routing: Provides interconnection between


separate networks
– Core service necessary for Internet to function
– Linux provides support for routing and is easily
customizable
• File Transfer Protocol (FTP) Services: Most
common and efficient method for transferring files
over the Internet

Linux+ Guide to Linux Certification, 2e 38


Internet Servers:
Firewalls and Proxy Services

• Firewall: Protects companies from outside intruders


on the Internet
– Linux has firewall support built into the kernel
• Proxy server: requests Internet resources such as
Web sites and FTP sites on behalf of the computer
inside the company

Linux+ Guide to Linux Certification, 2e 39


Internet Servers:
Web Services and News Services

• Web services: Web servers host information (text,


pictures, music, binary data, and video)
– Can also process programs known as Common
Gateway Interface (CGI) scripts and provide secure
connections
• News services: News servers allow users to post
messages in forums called newsgroups
– Most Web servers do not provide means for users to
communicate

Linux+ Guide to Linux Certification, 2e 40


Internet Servers: DNS Services

• Computers communicating on a network need to


be uniquely identified
– Each computer is assigned an Internet Protocol (IP)
address
• Long string of numbers
• Allows computers to identify and reference each other
• Fully Qualified Domain Name (FQDN): Masks IP
addresses with user-friendly names

Linux+ Guide to Linux Certification, 2e 41


File and Print Servers

• Linux is well-suited for centrally sharing resources


– More economical to share files and printers over a
network
– Inherently fast and light
– A distribution specific to a certain task can be
installed on the central server

Linux+ Guide to Linux Certification, 2e 42


Application Servers

• Application server: Intermediary between a client


computer and a database
• Database: Organized collection of data that is
arranged into tables of related information
• Database Management Systems (DBMS): Set of
programs designed for creation, modification,
manipulation, maintenance, and access of
information from databases

Linux+ Guide to Linux Certification, 2e 43


Supercomputers

• Clustering: Combining several smaller computers


to act as one large supercomputer
– Beowulf clustering: Most common Linux method of
clustering
• Scalability: Computers that can increase workload
as number of processors increases

Linux+ Guide to Linux Certification, 2e 44


Scientific/Engineering Workstation

• Scientific and engineering community often needs


customized programs
• OSS programs can be used or modified
– OSS software for physics, astrophysics, biophysics,
biocomputation, data mining, etc.

Linux+ Guide to Linux Certification, 2e 45


Office Workstation

• Workstation software designed for end users in


office and home environments
– Text editors and word processors
– Graphics editing software
– Desktop publishing software
– Financial software
– Office productivity suites

Linux+ Guide to Linux Certification, 2e 46


Summary

• Linux is an OS
• Kernel and additional software are freely developed
and improved upon by a large community of
software developers
• Published under the GPL; is called Open Source
Software (OSS)
• Companies find Linux a stable, low-risk, and
flexible alternative to other OSs

Linux+ Guide to Linux Certification, 2e 47


Summary (continued)

• Comes in different distributions, all having a


common kernel, but packaged with different OSS
applications
• Wide variety of documentation and resources exist:
Internet Web sites, HOWTOs, FAQs, newsgroups,
and LUGs
• Extremely versatile OS that provides a wide range
of workstation and server services

Linux+ Guide to Linux Certification, 2e 48


Linux+ Guide to Linux
Certification, Second Edition

Chapter 2
Preparing for Linux Installation
Objectives

• Describe common types of hardware and their


features
• Obtain the hardware and software information
necessary to install Linux

Linux+ Guide to Linux Certification, 2e 2


Understanding Hardware:
Central Processing Units (CPUs)

• Core component of any computer


– Also known as microprocessor or processor
• Two main components:
– Arithmetic logic unit (ALU): Mathematical
calculations and logic-based operations executed
here
– Control unit (CU): Instruction code or commands
loaded and carried out here

Linux+ Guide to Linux Certification, 2e 3


Understanding Hardware: CPUs
(continued)

• Processor architecture: Arrangement of a


processor’s integral electronics
• Two main processor architectures:
– Complex Instruction Set Computer (CISC)
– Reduced Instruction Set Computer (RISC)

Linux+ Guide to Linux Certification, 2e 4


Understanding Hardware: CPUs
(continued)
• Clock speed: Internal time cycle of a processor
– Determines speed that processor executes
commands
– Measured in Megahertz (MHz)
• A processor may require one cycle to complete a
command or may be superscalar
• Amount of information a processor can process at
one time is a major factor in clock speed
– Measured in binary digits (bits)
– The more information that can be worked on at
once, the faster data can be manipulated
Linux+ Guide to Linux Certification, 2e 5
Understanding Hardware: CPUs
(continued)
• Cache: Temporary store of information
– Cache size and location affect a processor’s ability
to calculate larger volumes of data
• Level 1 (L1) cache: Cache stored in the processor
itself
• Level 2 (L2) cache: Cache stored in a separate
computer chip
– Connected to processor via high speed link
• Level 3 (L3) cache: Cache stored on a separate
computer chip
– Connected directly to processor
Linux+ Guide to Linux Certification, 2e 6
Understanding Hardware: CPUs
(continued)

• Multiple processors can work together


– Perform the same tasks faster
– Symmetric Multi-Processing (SMP): Allows OS and
memory to use both processors simultaneously for
any task
– ASymmetric Multi-Processing (ASMP): Each
processor given a set of tasks to complete
independently

Linux+ Guide to Linux Certification, 2e 7


Understanding Hardware:
Physical Memory

• Storage area for information that is directly wired


through circuit boards to the processor
• Two main categories:
– Random Access Memory (RAM)
• Volatile memory
– Read Only Memory (ROM)

Linux+ Guide to Linux Certification, 2e 8


Understanding Hardware:
Physical Memory―RAM

• Requires constant supply of electricity to maintain


stored information
• Directly related to computer performance
• Two major categories:
– Dynamic RAM (DRAM)
– Static RAM (SRAM)

Linux+ Guide to Linux Certification, 2e 9


Understanding Hardware:
Physical Memory―RAM (continued)

• Three main types of DRAM sticks:


– Single In-line Memory Modules (SIMM)
• No longer produced
– Dual In-line Memory Modules (DIMM)
– Small Outline Dual In-line Memory Modules
(SODIMM)
• Used in portable notebook computers and Macintosh
systems

Linux+ Guide to Linux Certification, 2e 10


Understanding Hardware:
Physical Memory―RAM (continued)

• Three recent DIMM technologies:


– Synchronous Dynamic Random Access Memory
(SDRAM)
– Double Data Rate Synchronous Dynamic Random
Access Memory (DDR SDRAM)
– Rambus Dynamic Random Access Memory
(RDRAM)

Linux+ Guide to Linux Certification, 2e 11


Understanding Hardware:
Physical Memory―ROM

• Read-only Memory: Physical memory that can be


read but not written to
– Nonvolatile
• Basic Input/Output System (BIOS) ROM: Stores
programs used to initialize hardware components
when starting computer

Linux+ Guide to Linux Certification, 2e 12


Understanding Hardware:
Physical Memory―ROM Variants

• Programmable Read Only Memory (PROM): Can


only be written to once
• Erasable Programmable Read Only Memory
(EPROM): Contents can be repeatedly erased and
rewritten as a whole
• Electronically Erasable Programmable Read Only
Memory (EEPROM): Whole or partial contents can
be repeatedly erased/rewritten

Linux+ Guide to Linux Certification, 2e 13


Understanding Hardware:
Disk Drives

• Most information in a computer maintained using


nonvolatile media, not consisting of integrated
circuits
– Hard disk
– Floppy disk
– CD-ROM, DVD
– CD-RW, DVD-RW disk
– Zip disk
– Flash Memory

Linux+ Guide to Linux Certification, 2e 14


Understanding Hardware:
Disk Drives―Hard Disk Drives

• Not directly wired to the processor


– Pass through a hard disk controller card
• Controls flow of information to and from the hard disk
drive (HDD)
• Two types of controller cards:
– Integrated Drive Electronics (IDE)
• Also known as Advanced Technology Attachment
(ATA) controllers
– Small Computer System Interface (SCSI)

Linux+ Guide to Linux Certification, 2e 15


Understanding Hardware:
Disk Drives―HDDs (continued)

Table 2-1: IDE HDD configurations

Linux+ Guide to Linux Certification, 2e 16


Understanding Hardware:
Disk Drives―HDDs (continued)

• Partitions: Small, manageable sections of a hard


drive
• Filesystems: Specify how data should reside on the
hard disk itself
– A partition must be formatted with a filesystem

Linux+ Guide to Linux Certification, 2e 17


Understanding Hardware:
Disk Drives―HDDs (continued)

• Primary partitions: Major unique and separate HDD


divisions
• Extended partitions: Partitions that can be further
subdivided into logical drives
• Master Boot Record (MBR): Table of all partition
information for a hard disk
– Stored outside of all partitions

Linux+ Guide to Linux Certification, 2e 18


Understanding Hardware:
Disk Drives―HDDs (continued)

Table 2-2: Example partitioning scheme


for a primary master IDE HDD

Linux+ Guide to Linux Certification, 2e 19


Understanding Hardware: Disk
Drives―Other Information Storage
Devices
• Removable media: Information storage media that
can be removed from the computer
– Transferable between computers
• Floppy disks: Store information electro-
magnetically
– Used in floppy disk drives
• Zip disks: Similar to floppy disks
– Can store much more information
– Used in zip drives

Linux+ Guide to Linux Certification, 2e 20


Understanding Hardware: Disk
Drives―Other Information Storage
Devices (continued)
• DVDs and CD-ROMs: Use lasers to read reflected
light pulses
– Greater data transfer speed
– Larger storage capacity
– More resistance to data loss than floppy disks or ZIP
disks
• Flash memory drives: Use EEPROM chips to store
information

Linux+ Guide to Linux Certification, 2e 21


Understanding Hardware: Mainboards
and Peripheral Components
• Bus: Pathway information takes from one hardware
device to another via a mainboard
• Mainboard (also called a motherboard): Circuit
board that connects all other hardware components
together via slots or ports on the circuit board
• Peripheral components: Attach to the mainboard of
a computer
– e.g., video cards, sound cards, and network
interface cards (NICs)
– Connected via an Input/Output bus represented by
different slots or ports on the mainboard
Linux+ Guide to Linux Certification, 2e 22
Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• Three common slots for peripheral devices:
– Industry Standard Architecture (ISA): Information
transfer at 8 MHz
– Peripheral Component Interconnect (PCI):
Information transfer at 33 MHz
• Can use Direct Memory Access (DMA)
– Accelerated Graphics Port (AGP): Information
transfer over 66 MHz
• Designed for video card peripherals

Linux+ Guide to Linux Certification, 2e 23


Understanding Hardware: Mainboards
and Peripheral Components
(continued)

Figure 2-1: Mainboard components


Linux+ Guide to Linux Certification, 2e 24
Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• Other peripherals may have external connections
to mainboard
– PS/2
– COM (Serial)
– LPT
– USB
– IEEE1394 (Firewire)
– PCMCIA

Linux+ Guide to Linux Certification, 2e 25


Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• PS/2 ports: Connect keyboards and mice to
computers
• COM ports: Connect a variety of peripherals to the
mainboard
– Serial port
• LPT ports: Most commonly connect printers to the
mainboard
– Parallel ports

Linux+ Guide to Linux Certification, 2e 26


Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• Universal Serial Bus (USB) port: Connects
peripheral components such as mice, printers, and
scanners
– Hot-swappable: Can be attached to the computer
while it is running
• FireWire (IEEE1394): Hot-swappable variant of
USB commonly used to connect SCSI hard disks,
scanners, digital cameras, and CD-RW drives

Linux+ Guide to Linux Certification, 2e 27


Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• Personal Computer Memory Card International
Association (PCMCIA) ports: Allow a small card to
be inserted into the computer with electronics
necessary to provide certain functionality
• Advanced Power Management (APM): BIOS
feature that shuts off power to unused peripheral
devices

Linux+ Guide to Linux Certification, 2e 28


Understanding Hardware: Mainboards
and Peripheral Components
(continued)
• Interrupt Request Line (IRQ): Specifies a unique
channel from a device to the CPU
• Input/Output (IO) address: Small working area of
RAM where CPU can pass information to and
receive information from a device
• Plug-and-Play (PnP): OS and peripheral devices
that automatically assign the correct IRQ, I/O
address, and DMA settings

Linux+ Guide to Linux Certification, 2e 29


Understanding Hardware: Video
Adapter Cards and Monitors

• Video adapter cards: Provide graphical display


when connected to a monitor
– Commonly referred to as video cards
• Resolution: Total number of pixels that can be
displayed on a computer video screen
• Color depth: Total set of colors that can be
displayed on a computer video screen

Linux+ Guide to Linux Certification, 2e 30


Understanding Hardware: Video
Adapter Cards and Monitors
(continued)

Table 2-3: Memory requirements for


screen resolution and color depths

Linux+ Guide to Linux Certification, 2e 31


Understanding Hardware: Video
Adapter Cards and Monitors
(continued)
• Refresh rate: Rate at which information displayed
on a video screen is refreshed
– Measured in Hertz (Hz)
– Two types of refresh rates:
• HSync (horizontal refresh)
• VSync (vertical refresh)

Linux+ Guide to Linux Certification, 2e 32


Understanding Hardware:
Keyboards and Mice

• Facilitates user input and direction


• Variety of ways to connect to motherboard
– Serial port
– Large circular AT 5-pin connector
– Small circular PS/2 6-pin connector
– USB connection
– Wireless or radio connection
• Check hardware components against a Hardware
Compatibility List (HCL)

Linux+ Guide to Linux Certification, 2e 33


Gathering Preinstallation Information

Table 2-4: Red Hat 7.2 hardware requirements


Linux+ Guide to Linux Certification, 2e 34
Gathering Preinstallation Information
(continued)

Table 2-5: Sample pre-installation checklist

Linux+ Guide to Linux Certification, 2e 35


Gathering Preinstallation Information
(continued)

Table 2-5 (continued): Sample pre-installation checklist

Linux+ Guide to Linux Certification, 2e 36


Gathering Hardware Information

• Tools and resources to check hardware against a


preinstallation checklist:
– Computer manuals
– Windows System Information tool (if Windows
already installed)
– Windows Device Manager (if Windows already
installed)

Linux+ Guide to Linux Certification, 2e 37


Gathering Hardware Information
(continued)

Figure 2-2: The Windows System Information tool

Linux+ Guide to Linux Certification, 2e 38


Gathering Hardware Information
(continued)

Figure 2-3: The Windows Device Manager

Linux+ Guide to Linux Certification, 2e 39


Gathering Hardware Information
(continued)

Figure 2-4: The Windows Display applet


Linux+ Guide to Linux Certification, 2e 40
Gathering Hardware Information
(continued)

Figure 2-5: System Power-On Self Test (POST)

Linux+ Guide to Linux Certification, 2e 41


Gathering Hardware Information
(continued)

Figure 2-6: BIOS Setup Utility

Linux+ Guide to Linux Certification, 2e 42


Gathering Software Information

• Identifying system network configuration:


– Hostname
– IP address
– Netmask
– Gateway
– DNS servers
• Resolve FQDNs

Linux+ Guide to Linux Certification, 2e 43


Gathering Software Information
(continued)

• Dynamic Host Configuration Protocol (DHCP)


server: Server on network providing IP
configuration to requesting computers
– If selected during installation, Linux will attempt to
get IP settings from a DHCP server on the network

Linux+ Guide to Linux Certification, 2e 44


Gathering Software Information
(continued)

Table 2-6: Common Linux packages

Linux+ Guide to Linux Certification, 2e 45


Gathering Software Information
(continued)

Table 2-6 (continued): Common Linux packages

Linux+ Guide to Linux Certification, 2e 46


Summary

• Understand the hardware before an installation


– Allows you to make appropriate choices
– Verify that the installation was successful
• CPUs process most instructions in a computer
• Two CPU architectures: RISC and CISC
• Computer memory can be volatile (RAM) or
nonvolatile (ROM)

Linux+ Guide to Linux Certification, 2e 47


Summary (continued)

• Most information is stored on hard disks, floppy


disks, and CD-ROMs in a nonvolatile manner
– Two main types of hard disks: SCSI and IDE
• Peripheral components (video adapter cards,
sound cards, mice, keyboards, NICs) attach to
mainboard via an expansion slot or port
• Common expansion slots: ISA, PCI, and AGP
• Common ports: PS/2, serial, parallel, USB,
FireWire, and PCMCIA

Linux+ Guide to Linux Certification, 2e 48


Summary (continued)

• All peripherals must have a unique IRQ and I/O


address to communicate with the processor
– Can use DMA to bypass some processor operations
• Hardware information can be gathered from
computer manuals, BIOS, or other OSs
• Can set software information at installation

Linux+ Guide to Linux Certification, 2e 49


Linux+ Guide to Linux
Certification, Second Edition

Chapter 3
Linux Installation and Usage
Objectives

• Install Red Hat Fedora Linux using good practices


• Outline the structure of the Linux interface
• Enter basic shell commands and find command
documentation
• Properly shut down the Linux operating system

Linux+ Guide to Linux Certification, 2e 2


Installing Linux: Installation Methods

• FTP server
• HTTP Web server
• NFS server
• SMB server
• Virtual Network Computing (VNC) server
• Packages on hard disk

Linux+ Guide to Linux Certification, 2e 3


Performing the Installation: Starting
the Installation

• Boot from first Red Hat Fedora Linux CD-ROM


• Largest problem is initiating a graphical installation
– Disable framebuffer
• Framebuffer: Abstract representation of video
adapter card hardware
– Instead of direct communication with video adapter

Linux+ Guide to Linux Certification, 2e 4


Performing the Installation: Starting
the Installation (continued)

Figure 3-1: Beginning a Red Hat installation


Linux+ Guide to Linux Certification, 2e 5
Performing the Installation: Starting
the Installation (continued)

• Press F2 at Welcome screen to get installation


options
• Check media for errors prior to installation
– Optional, but recommended

Linux+ Guide to Linux Certification, 2e 6


Performing the Installation: Starting
the Installation (continued)

Figure 3-2: Viewing installation options

Linux+ Guide to Linux Certification, 2e 7


Choosing the Language, Keyboard,
Mouse, and Monitor

• Keyboard model and layout automatically detected


• Check “Emulate 3 Button” if mouse does not have
third button
• Most monitors automatically detected
– If not, try to locate on list of monitor models or use
generic model with correct horizontal and vertical
sync
• Incorrect monitor settings can damage monitor

Linux+ Guide to Linux Certification, 2e 8


Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Figure 3-4: Selecting an installation language


Linux+ Guide to Linux Certification, 2e 9
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Figure 3-5: Verifying keyboard configuration


Linux+ Guide to Linux Certification, 2e 10
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Figure 3-6: Selecting a mouse type


Linux+ Guide to Linux Certification, 2e 11
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Figure 3-7: Verifying monitor configuration


Linux+ Guide to Linux Certification, 2e 12
Specifying the Installation Type

• Personal Desktop
– GUI environment and common applications
• Workstation
– Same as Personal Desktop plus administrative and
network tools
• Server
– Several server services
• Custom

Linux+ Guide to Linux Certification, 2e 13


Specifying the Installation Type
(continued)

Figure 3-8: Choosing an installation type


Linux+ Guide to Linux Certification, 2e 14
Hard Disk Partitioning

• Filesystems can be accessed if attached (mounted)


to a directory
• Minimum of two partitions
– Partition for root directory
– Partition for virtual memory (swap memory)
• Area on hard disk used to store information normally
residing in physical memory (RAM)
• Automatic or manual partitioning

Linux+ Guide to Linux Certification, 2e 15


Hard Disk Partitioning (continued)

Table 3-1: Common Linux filesystems and sizes

Linux+ Guide to Linux Certification, 2e 16


Hard Disk Partitioning (continued)

Figure 3-9: Choosing a disk partitioning method


Linux+ Guide to Linux Certification, 2e 17
Hard Disk Partitioning (continued)

• Different types of filesystems


– Ext2: Used on most Linux computers
– Ext3: Performs journaling
– Vfat: Compatible with Windows’ FAT filesystem
– REISER: Performs journaling
• Journaling: Keeps track of the information written to
the hard drive
• Disk Druid: Graphical partitioning program

Linux+ Guide to Linux Certification, 2e 18


Hard Disk Partitioning (continued)

Figure 3-10: The Disk Druid partitioning utility


Linux+ Guide to Linux Certification, 2e 19
Hard Disk Partitioning (continued)

Figure 3-11: Creating a new partition


Linux+ Guide to Linux Certification, 2e 20
Configuring the Boot Loader

• Boot loader: Program started by BIOS ROM


– Loads kernel into memory
– Can also boot other existing OSs
• GRand Unified Bootloader (GRUB): Boot loader
configured during Fedora Linux installation
• Dual booting: Choose OS to boot at startup

Linux+ Guide to Linux Certification, 2e 21


Configuring the Boot Loader
(continued)

Figure 3-12: Configuring a boot loader


Linux+ Guide to Linux Certification, 2e 22
Configuring the Boot Loader
(continued)

• Boot loader usually resides on the MBR or on first


sector of / or /boot partition
• Kernel parameters: Information passed to Linux
kernel via the boot loader
• Large Block Addressing 32-bit (LBA32): Enables
Large Block Addressing in boot loader
– For large hard disks not fully supported by the BIOS

Linux+ Guide to Linux Certification, 2e 23


Configuring the Boot Loader
(continued)

Figure 3-13: Configuring advanced boot loader options


Linux+ Guide to Linux Certification, 2e 24
Configuring the Network and Firewall

Figure 3-14: Specifying a network configuration


Linux+ Guide to Linux Certification, 2e 25
Configuring the Network and Firewall
(continued)

• Will NIC be activated at boot time?


• Manual IP configuration
– Set IP address, Netmask, host name, gateway,
primary domain name space (DNS)
• Automatic IP configuration via DHCP
• Firewall prevents traffic from entering computer
– Customize which traffic is allowed through

Linux+ Guide to Linux Certification, 2e 26


Configuring the Network and Firewall
(continued)

Figure 3-15: Configuring a firewall


Linux+ Guide to Linux Certification, 2e 27
Choosing a System Language and
Time Zone

Figure 3-16: Selecting additional language support


Linux+ Guide to Linux Certification, 2e 28
Choosing a System Language and
Time Zone (continued)

Figure 3-17: Choosing a time zone


Linux+ Guide to Linux Certification, 2e 29
Creating the Root User

• Authentication: Users log in via valid user name


and password
• Configure two user accounts
– Administrator account (root)
• Full rights to system
– Regular user account

Linux+ Guide to Linux Certification, 2e 30


Creating the Root User (continued)

Figure 3-18: Setting a root password


Linux+ Guide to Linux Certification, 2e 31
Selecting Packages

Figure 3-19: Selecting packages


Linux+ Guide to Linux Certification, 2e 32
Installing Packages

Figure 3-19: Package Installation


Linux+ Guide to Linux Certification, 2e 33
Completing the Firstboot Wizard

• Complete the installation


– License agreement
– Graphics settings
– User accounts and authentication
– Install additional software
• Log in with user account for daily tasks
• Shadow password: stored in separate DB from
user accounts
• MD5: password encryption method

Linux+ Guide to Linux Certification, 2e 34


Completing the Firstboot Wizard
(continued)

Figure 3-22: Setting the date and time

Linux+ Guide to Linux Certification, 2e 35


Completing the Firstboot Wizard
(continued)

Figure 3-23: Configuring screen resolution and color depth

Linux+ Guide to Linux Certification, 2e 36


Completing the Firstboot Wizard
(continued)

Figure 3-24: Creating a regular user account

Linux+ Guide to Linux Certification, 2e 37


Completing the Firstboot Wizard
(continued)

Figure 3-25: Configuring user information


Linux+ Guide to Linux Certification, 2e 38
Completing the Firstboot Wizard
(continued)

Figure 3-26: Configuring authentication


Linux+ Guide to Linux Certification, 2e 39
Basic Linux Language: Shells,
Terminals, and the Kernel

• Terminal: Channel allowing users to log on to the


kernel locally or across a network
• Shell: Transfers user input to kernel
• BASH Shell (Bourne Again Shell): Default Linux
shell
– Command line shell
• Linux allows multiple terminals, each with its own
shell

Linux+ Guide to Linux Certification, 2e 40


Basic Linux Language: Shells,
Terminals, and the Kernel (continued)

Figure 3-27: Shells, terminals, and the kernel

Linux+ Guide to Linux Certification, 2e 41


Basic Linux Language: Shells,
Terminals, and the Kernel (continued)
• Graphical Interface
– Start GUI environment on top of BASH shell o
– Or, switch to a graphical terminal
• e.g., GNOME Display Manager (gdm)
• From the local server, use key combinations to
change to separate terminal
• Command-line terminal may be accessed from GUI
environment
• Command prompt:
– Root user: #
– Regular user: $
Linux+ Guide to Linux Certification, 2e 42
Basic Linux Language: Shells,
Terminals, and the Kernel (continued)

Table 3-2: Common Linux terminals

Linux+ Guide to Linux Certification, 2e 43


Basic Linux Language: Shells,
Terminals, and the Kernel (continued)

Figure 3-29: Accessing a command-line


terminal in a GUI environment
Linux+ Guide to Linux Certification, 2e 44
Basic Shell Commands

• Commands: Indicate name of program to execute


– Case sensitive
• Options: Specific letters starting with “-” appearing
after command name
– Alter way command works
• Arguments: Specify a command’s working
parameters

Linux+ Guide to Linux Certification, 2e 45


Basic Shell Commands (continued)

Table 3-3: Some Common Linux commands

Linux+ Guide to Linux Certification, 2e 46


Shell Metacharacters

• Metacharacters: Characters with a special meaning


– e.g., $
• Refers to a variable

Linux+ Guide to Linux Certification, 2e 47


Shell Metacharacters (continued)

Table 3-4: Common BASH Shell metacharacters

Linux+ Guide to Linux Certification, 2e 48


Getting Command Help
• Linux distributions contain many commands
• Manual pages: Most common form of
documentation for Linux commands
– “man” pages
– At command prompt, type “man” followed by a
command name
– Contain different sections
• Info pages: Set of local, easy-to-read command
syntax documentation
– At command prompt, type “info” followed by a
command name
Linux+ Guide to Linux Certification, 2e 49
Getting Command Help (continued)

Table 3-5: Manual page section numbers

Linux+ Guide to Linux Certification, 2e 50


Shutting Down the Linux System

Table 3-6: Commands to halt and reboot the Linux operating


system

Linux+ Guide to Linux Certification, 2e 51


Summary

• Most software information can be specified at


installation
– Network configuration and package selection should
be carefully planned before installation
• CD-ROM–based installation
– Easiest
– Most common
– Rarely requires installation boot disk

Linux+ Guide to Linux Certification, 2e 52


Summary (continued)

• Installation prompts for language, boot loader, hard


disk partitions, network configuration, firewall
configuration, time zone, user accounts,
authentication, and package selection
• Users must log in to a terminal and receive a shell
before they are able to interact with the Linux
system and kernel

Linux+ Guide to Linux Certification, 2e 53


Summary (continued)

• From any type of terminal you can enter


commands, options, and arguments at a shell
prompt to perform system tasks, obtain command
help, or shut down the Linux system
• The shell is case sensitive and understands a
variety of special characters called shell
metacharacters, which should be protected if their
special meaning is not required

Linux+ Guide to Linux Certification, 2e 54


Linux+ Guide to Linux
Certification, Second Edition

Chapter 4
Exploring Linux
Filesystems
Objectives

• Understand and navigate the Linux directory


structure using relative and absolute pathnames
• Describe the various types of Linux files
• View filenames and file types
• Use shell wildcards to specify multiple filenames

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Display the contents of text files and binary files


• Search text files for regular expressions using grep
• Identify common text editors used today
• Use the vi editor to manipulate text files

Linux+ Guide to Linux Certification, 2e 3


The Linux Directory Structure

• Directory: Used to organize other files into a logical


tree structure
• Absolute pathname: Pathname from the root
directory to a certain file or directory
• Root: The top level directory
– referred to using the / character

Linux+ Guide to Linux Certification, 2e 4


The Linux Directory Structure
(continued)

Figure 4-1: The Windows filesystem structure

Figure 4-2: The Linux filesystem structure

Linux+ Guide to Linux Certification, 2e 5


Changing Directories

• Home directory: Unique to each user


• pwd (print working directory) command: Displays
current directory in the directory tree
• cd (change directory) command: Change the
current directory in the directory tree
• ~ metacharacter: Refers to home directory
• Relative pathname: Pathname of file or directory
relative to current directory

Linux+ Guide to Linux Certification, 2e 6


Changing Directories (continued)

• Subdirectory: Directory residing within another


directory
• Tab-completion: Pressing the Tab key fills in
remaining characters of a unique filename or
directory name
– BASH shell feature

Linux+ Guide to Linux Certification, 2e 7


Viewing Files and Directories: File Types

• Text files: Store information in a readable text


format
• Binary data files: Store information associated with
executable programs
• Executable program files
• Directory files

Linux+ Guide to Linux Certification, 2e 8


Viewing Files and Directories: File Types
(continued)

• Linked files: Associated with another file


• Special device files: Represent system devices
• Named pipes: Identify channel that passes
information between processes
• Socket files: Allow a process on another computer
to write to a local file

Linux+ Guide to Linux Certification, 2e 9


Filenames

• Filename: Identifier given to a file


• Filename extensions: Identifiers following a dot (.)
at end of filename
– Denote file type
– Most files on Linux do not have file extensions

Linux+ Guide to Linux Certification, 2e 10


Filenames (continued)

Table 4-1: Common filename extensions


Linux+ Guide to Linux Certification, 2e 11
Filenames (continued)

Table 4-1 (continued): Common filename extensions

Linux+ Guide to Linux Certification, 2e 12


Listing Files

• ls command: List the files in a directory


– May pass an argument indicating the directory to be
listed
• –F switch: Argument to list file types
• –l switch: Argument to list long file listings
• Alias: Shortcut for a command
• ll command: Alias for ls -l
• File command: Displays file type of any file

Linux+ Guide to Linux Certification, 2e 13


Listing Files (continued)

• Hidden files: Files not normally displayed to user


– Filenames start with a dot (.)
– Configuration files often hidden
– ls –a command: Displays hidden files

Linux+ Guide to Linux Certification, 2e 14


Listing Files (continued)

Table 4-2: Common options to the ls command


Linux+ Guide to Linux Certification, 2e 15
Listing Files (continued)

Table 4-2 (continued): Common options to the ls command

Linux+ Guide to Linux Certification, 2e 16


Wildcard Metacharacters

• Wildcard metacharacter: Used to simplify


commands specifying multiple filenames
– Can be used with most Linux filesystem commands

Linux+ Guide to Linux Certification, 2e 17


Wildcard Metacharacters (continued)

Table 4-3: Wildcard metacharacters

Linux+ Guide to Linux Certification, 2e 18


Displaying Content of Text Files

• Concatenation: Joining text together


• cat command: Displays (concatenates) contents of
a text file to the screen
– -n switch: Displays line number and contents
• Log files: Contain records of past system events
– New events appended to end
• tac command: Displays files in reverse order
• head command: View first few lines of a file

Linux+ Guide to Linux Certification, 2e 19


Displaying Content of Text Files
(continued)

• tail command: View last few lines of a file


– Can also specify what line number to start at
• more command: Displays text files page-by-page
– Space key goes to next page
– Enter key goes to next line
• less command: Same as more command, but can
also use cursor to scroll

Linux+ Guide to Linux Certification, 2e 20


Displaying Content of Text Files
(continued)
• more and less can be used with output of other
commands
– If output is too large to fit on terminal screen, use “|”
metacharacter
– e.g., ls -l | more

Linux+ Guide to Linux Certification, 2e 21


Displaying the Contents of Binary Files

• Typically use program that created the file


• strings command: Searches for and displays text
characters in a binary file
– Might indicate purpose of binary file
• od command: Displays contents of file in octal
format (numeric base 8 format)

Linux+ Guide to Linux Certification, 2e 22


Searching for Text Within Files

• Text tools: Search for and manipulate text


• Regular expressions (regexp): Text wildcards that
assist search for specific text
– Match patterns of text
– Used by many text tools and programming
languages
• Including grep, emacs, C++, PERL, and many more

Linux+ Guide to Linux Certification, 2e 23


Regular Expressions

• Different from wildcard metacharacters


– Wildcard metacharacters interpreted by shell;
regexps interpreted by text tools
– Wildcard metacharacters match characters in
filenames; regexps match characters within text files
– More regexps than wildcard metacharacters
• Common and extended regexps

Linux+ Guide to Linux Certification, 2e 24


Regular Expressions (continued)

Table 4-4: Regular expressions


Linux+ Guide to Linux Certification, 2e 25
Regular Expressions (continued)

Table 4-4 (continued): Regular expressions

Linux+ Guide to Linux Certification, 2e 26


The grep Command

• grep (global regular expression print) command:


Displays lines in a text file matching a given regexp
• egrep command: Displays lines of text that match
extended regexps
• fgrep command: Does not interpret any regular
expressions
– Returns results much faster than egrep
• grep requires two arguments
– Text to search for and files to search

Linux+ Guide to Linux Certification, 2e 27


Editing Text Files: The vi Editor
• One of the oldest and most popular text editors for
UNIX OSs
• Vim: Linux equivalent of vi
– Standard on most Linux distributions
• Advantage is portability, not usability
– Used on Unix and Linux
• Bi-modal editor (two possible modes):
– Command mode: Performs text editing tasks not
related to inserting text
– Insert mode: Inserts text, but nothing else
• User environment is customizable

Linux+ Guide to Linux Certification, 2e 28


Editing Text Files: The vi Editor
(continued)

Table 4-5: Common keyboard keys


used to change to and from insert mode

Linux+ Guide to Linux Certification, 2e 29


Editing Text Files: The vi Editor
(continued)

Table 4-6: Key combinations commonly used in command mode

Linux+ Guide to Linux Certification, 2e 30


Editing Text Files: The vi Editor
(continued)

Table 4-6 (continued): Key combinations


commonly used in command mode

Linux+ Guide to Linux Certification, 2e 31


Editing Text Files: The vi Editor
(continued)

Table 4-6 (continued): Key combinations


commonly used in command mode

Linux+ Guide to Linux Certification, 2e 32


Editing Text Files: The vi Editor
(continued)

Table 4-7: Key combinations commonly used at the


command mode : prompt
Linux+ Guide to Linux Certification, 2e 33
Other Common Text Editors

• Mcedit editor (Midnight Commander Editor): Easy-


to-use text editor
– Supports regexp
– Supports use of mouse for highlighting text
• Emacs (Editor MACroS) editor: Comparable
functionality to vi
– Ctrl key combinations to perform special functions
– Supports LISP (LISt Processing) artificial intelligence
programming language

Linux+ Guide to Linux Certification, 2e 34


Other Common Text Editors
(continued)

Table 4-8: Keyboard functions commonly


used in the GNU emacs editor

Linux+ Guide to Linux Certification, 2e 35


Other Common Text Editors
(continued)

• Emacs editor is not easy to use


– Must memorize key combinations
• Xemacs editor: Version of Emacs for KDE or
GNOME GUI environments
– Easier to use than emacs
– Not available with every distribution

Linux+ Guide to Linux Certification, 2e 36


Other Common Text Editors
(continued)

Figure 4-3: The xemacs text editor


Linux+ Guide to Linux Certification, 2e 37
Other Common Text Editors
(continued)

• Graphical text editors available with most Linux


distributions:
– nedit editor
– gedit editor: Distributed with GNOME environment
– kedit editor: Distributed with KDE environment
• gedit and kedit offer more functionality than nedit

Linux+ Guide to Linux Certification, 2e 38


Other Common Text Editors
(continued)

Figure 4-4: The nedit text editor


Linux+ Guide to Linux Certification, 2e 39
Other Common Text Editors
(continued)

Figure 4-5: The gedit text editor


Linux+ Guide to Linux Certification, 2e 40
Other Common Text Editors
(continued)

Figure 4-6: The kedit text editor


Linux+ Guide to Linux Certification, 2e 41
Summary
• The Linux filesystem is arranged hierarchically
using a series of directories to store files
• Location of these directories and files can be
described using absolute or relative pathnames
• Accommodates many types of files: text files,
binary data, executable programs, directories,
linked files, and special device files
• The ls command is used to view filenames
– Wide range of options
• Wildcard metacharacters can simplify selection of
several files when using common Linux file
commands
Linux+ Guide to Linux Certification, 2e 42
Summary (continued)

• Text files are the most common file type whose


contents can be viewed by several utilities, such as
head, tail, cat, tac, more, and less
• Regular expression metacharacters can be used to
specify certain patterns of text when used with
certain programming languages and text tool
utilities such as grep
• vi (vim) is a powerful, bimodal text editor that is
standard on most UNIX and Linux systems

Linux+ Guide to Linux Certification, 2e 43


Linux+ Guide to Linux
Certification, Second Edition

Chapter 5
Linux Filesystem
Management
Objectives

• Explain the function of the Filesystem Hierarchy


Standard
• Use standard Linux commands to manage files and
directories
• Find files and directories on the filesystem
• Understand and create linked files

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Modify file and directory ownership


• Define and change Linux file and directory
permissions
• Identify the default permissions created on files and
directories
• Apply special file and directory permissions

Linux+ Guide to Linux Certification, 2e 3


The Filesystem Hierarchy Standard

• Filesystem Hierarchy Standard (FHS): Standard set


of directories for Linux and UNIX systems
– File and subdirectory contents
– Gives Linux software developers ability to locate files
on any Linux system
• Create non-distribution–specific software

Linux+ Guide to Linux Certification, 2e 4


The Filesystem Hierarchy Standard
(continued)

Table 5-1: Linux directories defined by FHS


Linux+ Guide to Linux Certification, 2e 5
The Filesystem Hierarchy Standard
(continued)

Table 5-1 (continued): Linux directories defined by FHS

Linux+ Guide to Linux Certification, 2e 6


Managing Files and Directories

• mkdir command: Creates new directories


– Arguments specify directory’s absolute or relative
pathname
• mv command: Moves files
– Two arguments minimum:
• Source file/directory (may specify multiple sources)
• Target file/directory
– Also used to rename files

Linux+ Guide to Linux Certification, 2e 7


Managing Files and Directories
(continued)

• cp command: Copies files


– Same arguments as mv command
• Recursive: Referring to itself and its own contents
– Recursive search includes all subdirectories in a
directory and their contents
– –r option

Linux+ Guide to Linux Certification, 2e 8


Managing Files and Directories
(continued)

• interactive mode: Prompts user before overwriting


files
– –i option
– –f option: Overrides interactive mode
• rm command: Removes files
– Arguments are a list of files
• rmdir command: Removes directories
– –r and –f options are helpful

Linux+ Guide to Linux Certification, 2e 9


Managing Files and Directories
(continued)

Table 5-2: Common Linux file management commands

Linux+ Guide to Linux Certification, 2e 10


Finding Files

• locate command: Search for files on system


– Shortcut to the slocate command
– Information returned may not fit on screen
• Use with more or less commands
– Uses indexed database of all files on system
• Find command: Recursively search for files starting
from a specified directory

Linux+ Guide to Linux Certification, 2e 11


Finding Files (continued)

Table 5-3: Common criteria used with find command

Linux+ Guide to Linux Certification, 2e 12


Finding Files (continued)

Table 5-3 (continued): Common criteria used with find command

Linux+ Guide to Linux Certification, 2e 13


Finding Files (continued)

• which command: Search for an executable file


– Searches the PATH variable
• PATH variable: Lists directories on system where
executable files are located
– Allows executable files to be run without specifying
absolute or relative path

Linux+ Guide to Linux Certification, 2e 14


Linking Files

• Symbolic link: One file is a pointer or shortcut to


another
• Hard link: Two files share the same data

Linux+ Guide to Linux Certification, 2e 15


Linking Files (continued)

• Filesystem has three main structural sections:


– Superblock: Contains general information about the
filesystem
• e.g., number of inodes and data blocks
– Inode: Describes a file or directory
• Unique inode number, file size, data block locations,
last date modified, permissions, and ownership
• Inode table: Consists of several inodes
– Data blocks: Data making up contents of a file

Linux+ Guide to Linux Certification, 2e 16


Linking Files (continued)

Figure 5-1: The structure of hard linked files

Linux+ Guide to Linux Certification, 2e 17


Linking Files (continued)

• ln (link) command: Create hard and symbolic links


– Two arguments:
• Existing file to link
• Target file to create as a link to existing file
– Use –s option to create symbolic link
• Hard linked files share two inodes
• Data blocks in symbolically linked files contain
pathname to target file

Linux+ Guide to Linux Certification, 2e 18


Linking Files (continued)

Figure 5-2: The structure of symbolically linked files

Linux+ Guide to Linux Certification, 2e 19


File and Directory Permissions

• All users must login with a username and password


• Users identified by username and group
memberships
– Access to resources depends on username and
group membership
– Must have required permissions

Linux+ Guide to Linux Certification, 2e 20


File and Directory Ownership

• Primary group: User’s default group


• During file creation, file’s owner and group owner
set to user’s username and primary group
– Same for directory creation
• touch command: Create an empty file

Linux+ Guide to Linux Certification, 2e 21


File and Directory Ownership
(continued)

• chown (change owner) command: Change


ownership of a file or directory
• chgrp (change group) command: Change group
owner of a file or directory

Linux+ Guide to Linux Certification, 2e 22


Managing File and Directory
Permissions
• Mode: Inode Section that stores permissions
• Three sections, based on the user(s) that receive
the permission:
– User permissions: Owner
– Group permissions: Group owner
– Other permissions: Everyone on system
• Three regular permissions may be assigned to
each user:
– Read
– Write
– Execute
Linux+ Guide to Linux Certification, 2e 23
Interpreting the Mode

Figure 5-3: The structure of a mode


Linux+ Guide to Linux Certification, 2e 24
Interpreting the Mode (continued)

• User: Refers to owner of a file or directory


• Owner: Refers to users with ability to change
permissions on a file or directory
• Other: Refers to all users on system
• Shell scripts: Text files containing instructions for
the shell to execute

Linux+ Guide to Linux Certification, 2e 25


Interpreting Permissions

Table 5-4: Linux permissions

Linux+ Guide to Linux Certification, 2e 26


Changing Permissions

• chmod (change mode) command: Change mode


(permissions) of files or directories
• Permissions stored in a file’s or a directory’s inode
as binary powers of two

Linux+ Guide to Linux Certification, 2e 27


Changing Permissions (continued)

Table 5-5: Criteria used within the chmod command

Linux+ Guide to Linux Certification, 2e 28


Changing Permissions (continued)

Figure 5-4: Numeric representation of the mode

Linux+ Guide to Linux Certification, 2e 29


Changing Permissions (continued)

Table 5-6: Numeric representations of the permissions in a mode

Linux+ Guide to Linux Certification, 2e 30


Default Permissions

• New files given rw-rw-rw- permissions by default


• umask: Takes away permissions on new files and
directories
• umask command: Displays the umask
• Changing the umask
– Use a new umask as an argument to the umask
command

Linux+ Guide to Linux Certification, 2e 31


Default Permissions (continued)

Figure 5-5: Performing a umask 022 calculation

Linux+ Guide to Linux Certification, 2e 32


Default Permissions (continued)

Figure 5-6: Performing a umask 007 calculation

Linux+ Guide to Linux Certification, 2e 33


Special Permissions

• SUID (Set User ID)


• SGID (Set Group ID)
• Sticky bit

Linux+ Guide to Linux Certification, 2e 34


Defining Special Permissions

• SUID
– If set on a file, user who executes the file becomes
owner of the file during execution
– No functionality when set on a directory
– Only applicable to binary compiled programs

Linux+ Guide to Linux Certification, 2e 35


Defining Special Permissions
(continued)

• SGID
– Applicable to files and directories
– If set on a file, user who executes the file becomes
member of the file’s group during execution
– If a user creates a file in a directory with SGID set,
the directory’s group owner is changed to match the
file’s group owner

Linux+ Guide to Linux Certification, 2e 36


Defining Special Permissions
(continued)

• Sticky bit
– Previously used to lock files in memory
– Currently only applicable to directories
– Ensures that a user can only delete files his/her own
files

Linux+ Guide to Linux Certification, 2e 37


Setting Special Permissions

• Special permissions require execute


• Mask the execute permission when displayed by
the ls –l command
• May be set even if file or directory does not have
execute permission
– Via chmod command
• Add an extra digit at front of permissions argument

Linux+ Guide to Linux Certification, 2e 38


Setting Special Permissions
(continued)

Figure 5-7: Representing special permissions in the mode

Linux+ Guide to Linux Certification, 2e 39


Setting Special Permissions
(continued)

Figure 5-8: Representing special permissions in the


absence of the execute permissions

Linux+ Guide to Linux Certification, 2e 40


Setting Special Permissions
(continued)

Figure 5-9: Numeric representation of regular


and special permissions

Linux+ Guide to Linux Certification, 2e 41


Summary
• The Linux directory tree obeys the FHS
• Many file management commands exist
• Files can be created as pointers to another file or
as a linked duplicate of another file
– Called symbolic and hard links, respectively
• Each file and directory has an owner and a group
owner
– Owner can change permissions and grant ownership

Linux+ Guide to Linux Certification, 2e 42


Summary (continued)

• Permissions can be set on the owner of a file,


members of the group of the file, and everyone on
the system (other)
• Can find files using locate, which, and find
• Three regular file and directory permissions (read,
write, execute) and three special file and directory
permissions (SUID, SGID, sticky bit)
• Permissions can be changed using chmod

Linux+ Guide to Linux Certification, 2e 43


Summary (continued)

• New files and directories receive default


permissions from the system
• The root user has all permissions to all files and
directories on the Linux filesystem
– root user can change the ownership of any file or
directory on the Linux filesystem

Linux+ Guide to Linux Certification, 2e 44


Linux+ Guide to Linux
Certification, Second Edition

Chapter 6
Linux Filesystem
Administration
Objectives
• Identify the structure and types of device files in the
/dev directory
• Understand common filesystem types and their
features
• Mount and unmount floppy disks to and from the
Linux directory tree
• Mount and unmount CD-ROMs to and from the
Linux directory tree
• Create hard disk partitions

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Mount and unmount hard disk partitions to and


from the Linux directory tree
• Monitor free space on mounted filesystems
• Check filesystems for errors
• Use hard disk quotas to limit user space usage

Linux+ Guide to Linux Certification, 2e 3


The /dev Directory

• Device file: File representing a system device


– Typically found in /dev directory
• Character devices: Transfer data to and from
system character by character
• Block devices: Transfer chunks or blocks of data
using physical memory as a buffer
– Fast data transfer
– CD-ROM, HDD, floppy disks

Linux+ Guide to Linux Certification, 2e 4


The /dev Directory (continued)

Table 6-1: Common device files

Linux+ Guide to Linux Certification, 2e 5


The /dev Directory (continued)

Table 6-1 (continued): Common device files

Linux+ Guide to Linux Certification, 2e 6


The /dev Directory (continued)

• Major number: Points to the device’s driver in the


Linux kernel
• Minor number: Indicates the particular device
• Device file type (block or character), major number,
and minor number make up a device file’s unique
characteristics
• mknod command: Can be used to re-create a
corrupted device file
– Must know file type, major, and minor numbers

Linux+ Guide to Linux Certification, 2e 7


Filesystems

• Filesystem: Organization imposed on physical


storage media
• Formatting: Creating a filesystem on a device

Linux+ Guide to Linux Certification, 2e 8


Filesystem Types

Table 6-2: Common Linux filesystems


Linux+ Guide to Linux Certification, 2e 9
Filesystem Types (continued)

Table 6-2 (continued): Common Linux filesystems

Linux+ Guide to Linux Certification, 2e 10


Mounting

• Mounting: Making a device accessible to users via


the logical directory tree
• Mount point: Directory to which a device is
attached
– Any existing directory can be a mount point
• Root filesystem: When Linux filesystem first turned
on, a filesystem on the hard drive is mounted to the
/ directory
– Contains most OS files

Linux+ Guide to Linux Certification, 2e 11


Mounting (continued)

Figure 6-1: The directory structure prior to mounting

Linux+ Guide to Linux Certification, 2e 12


Mounting (continued)

Figure 6-2: The directory structure after mounting a floppy device

Linux+ Guide to Linux Certification, 2e 13


Mounting (continued)

• mount command: Used to mount devices to mount


point directories
– With no options or arguments, lists currently
mounted filesystems
• umount command: Used to unmount devices from
mount point directories

Linux+ Guide to Linux Certification, 2e 14


Working with Floppy Disks
• Floppy disks must be prepared before use
– Formatted with a filesystem
• mkfs (make filesystem) command: Used to format a
disk device with a filesystem
– –t option: Specifies filesystem type
– Default is ext2 filesystem
• To mount or unmount floppies, must ensure that no
user is currently using the mount point directory
• fuser command: With the –u option, lists users
using a directory

Linux+ Guide to Linux Certification, 2e 15


Working with Floppy Disks (continued)

Table 6-3: Commands used to create filesystems

Linux+ Guide to Linux Certification, 2e 16


Working with Floppy Disks (continued)

• /etc/fstab file: Used to mount devices at boot time


– Also consulted when users do not specify enough
mount command arguments
– Six fields: Device to mount, mount point, type,
mount options, dump#, fsck#

Linux+ Guide to Linux Certification, 2e 17


Working with Floppy Disks (continued)

Table 6-4: Useful commands when


mounting and unmounting filesystems

Linux+ Guide to Linux Certification, 2e 18


Working with Floppy Disks (continued)

Figure 6-3: Mounting a floppy


device using a GUI environment

Linux+ Guide to Linux Certification, 2e 19


Working with Floppy Disks (continued)

Figure 6-4: Accessing filesystem devices in the KDE desktop


Linux+ Guide to Linux Certification, 2e 20
Working with CD-ROMs

• Most Linux systems have ATAPI-compliant IDE


CD-ROM drive
– Acts as a normal IDE hard disk
– Must configure in one of the following:
• Primary master (/dev/hda)
• Primary slave (/dev/hdb)
• Secondary master (/dev/hdc)
• Secondary slave (/dev/hdd)

Linux+ Guide to Linux Certification, 2e 21


Working with CD-ROMs (continued)

• Typically use iso9660 filesystem type and are not


writable
– Mount with –r (read-only) option
• Cannot be ejected until properly unmounted

Linux+ Guide to Linux Certification, 2e 22


Working with Hard Disks

• IDE HDDs must be configured in one of the


following:
– Primary master (/dev/hda)
– Primary slave (/dev/hdb)
– Secondary master (/dev/hdc)
– Secondary slave (/dev/hdd)
• Different device file for each

Linux+ Guide to Linux Certification, 2e 23


Working with Hard Disks (continued)

• SCSI hard disks well-suited to Linux servers


– Faster access speed
– Multiple hard drives can be attached to a controller
• Associated with different device files
– First SCSI HDD (/dev/sda)
– Second SCSI HDD (/dev/sdb)
– Third SCSI HDD (/dev/sdc)
– And so on

Linux+ Guide to Linux Certification, 2e 24


Hard Disk Partitioning
• As disk size increases, organization becomes more
difficult and chance of error increases
• Partition: A physical division of an HDD; can have
own filesystem
• Good practice to use more than two partitions
– Segregate different types of data
– Allow for use of multiple filesystem types on one
HDD
– Reduce chance that filesystem corruption will render
a system unusable
– Speeds up access to stored data; keep filesystems
small
Linux+ Guide to Linux Certification, 2e 25
Hard Disk Partitioning (continued)
• Track: Areas on a hard disk that form a concentric
circle of sectors
• Sector: Smallest unit of data storage on a hard disk
• Block: Combination of sectors; commonly used by
filesystem commands
• Cylinder: Series consisting of the same concentric
track on all of the metal platters inside a HDD
• Partition definitions stored in first readable sector of
the hard disk
– Master Boot Record (MBR) or master boot block
(MBB)
Linux+ Guide to Linux Certification, 2e 26
Hard Disk Partitioning (continued)

Figure 6-5: The physical areas of a hard disk

Linux+ Guide to Linux Certification, 2e 27


Hard Disk Partitioning (continued)

Table 6-5: Common hard disk partition


device files for /dev/hda and /dev/sda

Linux+ Guide to Linux Certification, 2e 28


Hard Disk Partitioning (continued)

Table 6-5 (continued): Common hard disk


partition device files for /dev/hda and /dev/sda

Linux+ Guide to Linux Certification, 2e 29


Hard Disk Partitioning (continued)

Figure 6-6: A sample Linux partitioning strategy

Linux+ Guide to Linux Certification, 2e 30


Hard Disk Partitioning (continued)

Figure 6-7: A sample dual-boot Linux partitioning strategy


Linux+ Guide to Linux Certification, 2e 31
Working with Hard Disk Partitions

• fdisk command: Create partitions after installation


– Specify hard disk partition as an argument
• tune2fs command: Create a journal file on the
filesystem
– Convert ext2 to ext3
• Edit /etc/fstab file to allow system to mount new
filesystems automatically at boot time

Linux+ Guide to Linux Certification, 2e 32


Monitoring Filesystems

• Check mounted filesystems periodically


– Errors
– Disk Space usage
– Inode usage

Linux+ Guide to Linux Certification, 2e 33


Disk Usage

• Using more filesystems typically results in less hard


disk space per filesystem
– Errors when filesystems fill up with data
• e.g., free space on / filesystem falls below 10%
• df (disk free space) command: Monitor free space
used by mounted filesystems
– –h option: More user friendly

Linux+ Guide to Linux Certification, 2e 34


Disk Usage (continued)

• du (directory usage) command: View size of a


directory and contents in Kilobytes
– –s option: Summarizes output
• dumpe2fs command: View total number of inodes
and free inodes for ext2 or ext3 filesystem
– Use –h option

Linux+ Guide to Linux Certification, 2e 35


Checking Filesystems for Errors

• Filesystem corruption: Errors in filesystem structure


preventing retrieval of data
– Commonly occurs due to improper system shutdown
• Syncing: Process of writing data stored in RAM to
the HDD
• Bad blocks: Unusable areas of a disk
– Cannot hold a magnetic charge

Linux+ Guide to Linux Certification, 2e 36


Checking Filesystems for Errors
(continued)

• fsck (filesystem check) command: Check a


filesystem for errors
– Filesystem must be unmounted
– –f option used to perform full check
• e2fsck command: Check ext2 and ext3 filesystems
• Reiserfsck: Check reiserfs filesystems

Linux+ Guide to Linux Certification, 2e 37


Checking Filesystems for Errors
(continued)

Table 6-6: Common options to the fsck command

Linux+ Guide to Linux Certification, 2e 38


Hard Disk Quotas

• If several users on a system, must be enough hard


disk space for each user’s files
• Hard disk quotas: User limits on filesystem usage
– Restrict number of files/directories or total disk
space usage
• Soft limit: User may exceed quota briefly
• Hard limit: Limit cannot be exceeded

Linux+ Guide to Linux Certification, 2e 39


Hard Disk Quotas (continued)

• quotaon and quotaoff commands: Toggle quotas


on and off
• edquota command: Edit user quotas
• repquota command: Report user quotas
• quota command: Allows regular users to view
quotas and current usage

Linux+ Guide to Linux Certification, 2e 40


Summary

• Disk devices are represented by device files that


reside in the /dev directory
• Each disk drive must contain a filesystem, which is
then mounted to the Linux directory tree for usage
using the mount command
• Hard disks must be partitioned into distinct sections
before filesystems are created on those partitions

Linux+ Guide to Linux Certification, 2e 41


Summary (continued)

• Many different filesystems available to Linux


• Important to monitor disk usage using the df, du,
and dumpe2fs commands to avoid running out of
storage space
• If hard disk space is limited, you can use hard disk
quotas to limit the space that each user has on
filesystems

Linux+ Guide to Linux Certification, 2e 42


Linux+ Guide to Linux
Certification, Second Edition

Chapter 7
Advanced Installation
Objectives

• Describe the types and structure of SCSI devices


• Identify default IRQs, I/O addresses, and DMAs
• Explain how Plug-and-Play can be used to assign
configuration to peripheral devices
• Explain how APM and ACPI can be used to control
power to peripheral devices

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Outline the steps used to install Linux from source


files on a DVD, hard disk, or network server
• Understand methods used to automate the Linux
installation
• Install Red Hat Fedora Linux using a kickstart file
• Troubleshoot the installation process

Linux+ Guide to Linux Certification, 2e 3


Advanced Hardware Configuration:
SCSI Hard Disk Drive Configuration

• Terminator: Prevents signals from bouncing back


and forth on a cable
• SCSI ID: Uniquely identifies devices attached to a
SCSI controller
– Target ID
– Identifies priority
• Logical Unit Number (LUN): Unique ID for each
device attached to a node in a SCSI chain

Linux+ Guide to Linux Certification, 2e 4


Advanced Hardware Configuration:
SCSI Hard Disk Drive Configuration
(continued)

Figure 7-1: Connecting SCSI devices


Linux+ Guide to Linux Certification, 2e 5
Advanced Hardware Configuration:
SCSI Hard Disk Drive Configuration
(continued)

Table 7-1: Common SCSI standards

Linux+ Guide to Linux Certification, 2e 6


Advanced Hardware Configuration:
SCSI Hard Disk Drive Configuration
(continued)

Figure 7-2: A 50-pin Centronics SCSI connector

Figure 7-3: A 50-pin LPT SCSI connector

Linux+ Guide to Linux Certification, 2e 7


Advanced Hardware Configuration:
SCSI Hard Disk Drive Configuration
(continued)

Figure 7-4: A 68-pin LPT SCSI connector

Linux+ Guide to Linux Certification, 2e 8


Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses
• IRQs: Method for peripheral devices to share
processor time
– Prioritize simultaneous service requests
• Polling: Processor polls devices to determine tasks
to be run
– Difficult to prioritize
• Interruption: Processor interrupted by devices
when resources needed
– Prioritize via IRQ

Linux+ Guide to Linux Certification, 2e 9


Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses (continued)

Figure 7-5: IRQ priorities

Linux+ Guide to Linux Certification, 2e 10


Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses (continued)

Table 7-2: Default IRQ assignments


Linux+ Guide to Linux Certification, 2e 11
Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses (continued)

• I/O address: Identifies working space in RAM for


peripheral devices
• DMA: Allows devices direct physical memory
access via unique channels
– Improves system performance

Linux+ Guide to Linux Certification, 2e 12


Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses (continued)

Table 7-3: Default I/O address assignments


Linux+ Guide to Linux Certification, 2e 13
Mainboard Flow Control: IRQs, DMAs,
and I/O Addresses (continued)

Table 7-4: Default DMA assignments

Linux+ Guide to Linux Certification, 2e 14


Plug-and-Play

• PnP: Automatically assigns configuration


information to devices
– IRQs, I/O addresses, DMAs
– Uses BIOS information to avoid conflicts
• Complimentary Metal Oxide Semiconductor
(CMOS): Memory on mainboard used to store
configuration information for boot process

Linux+ Guide to Linux Certification, 2e 15


APM and ACPI

• APM: Shuts off power to peripheral components as


needed
– Configured in BIOS
• Advanced Configuration and Power Interface
(ACPI): Configures peripheral’s power setting from
OS
– Monitor CPU temperature and battery power
– Standby mode and sleep mode
• Linux ACPI Client: Utility used to view ACPI
settings

Linux+ Guide to Linux Certification, 2e 16


RAID Configuration

• Fault tolerant: Device exhibiting minimum downtime


after failure
• Redundant Array of Inexpensive Disks (RAID):
Combines several HDDs’ storage space
– Hardware- or software-based
– Seven raid configurations

Linux+ Guide to Linux Certification, 2e 17


RAID Configuration (continued)

• Spanning: Two HDDs seen as one volume


– RAID level 0, not fault tolerant
• Disk striping: Write separate information to different
HDDs
– RAID level 0, not fault tolerant
– Decreases read/write time
• Disk mirroring: Two identical hard disks
– RAID level 1, fault tolerant

Linux+ Guide to Linux Certification, 2e 18


RAID Configuration (continued)

• Disk striping with parity: Write separate information


to HDDs and maintain parity information
– RAID level 5, fault tolerant
– Parity bits indicate what data is where
• Can be used to re-generate data when HDD fails
– Requires three HDDs minimum
– Most common RAID configuration

Linux+ Guide to Linux Certification, 2e 19


RAID Configuration (continued)

Figure 7-6: Organization of data on RAID level 5

Linux+ Guide to Linux Certification, 2e 20


Installation Methods

• International Standards Organization (ISO) image:


Large file containing exact copy of contents of a
CD-ROM or DVD
• CD-ROM is the most common and easiest method
for installing Linux
• Other methods for installing Linux
– DVD
– Network server
– Local hard disk

Linux+ Guide to Linux Certification, 2e 21


DVD Installation

• Similar to CD-ROM installation


• Only one DVD required, as opposed to multiple
CD-ROMs

Linux+ Guide to Linux Certification, 2e 22


Hard Disk Installation

• May install Linux directly from ISO images on hard


disk
– Must have sufficient free space outside partition
containing ISO images
• Create installation startup CD-ROM or bootable
USB flash memory drive
– Boot from this to start installation
• Installation will be text-based

Linux+ Guide to Linux Certification, 2e 23


Hard Disk Installation (continued)

Figure 7-7: Installation welcome screen


Linux+ Guide to Linux Certification, 2e 24
Hard Disk Installation (continued)

Figure 7-8: Language selection screen


Linux+ Guide to Linux Certification, 2e 25
Hard Disk Installation (continued)

Figure 7-9: Keyboard selection screen


Linux+ Guide to Linux Certification, 2e 26
Hard Disk Installation (continued)

Figure 7-10: Selecting an installation method


Linux+ Guide to Linux Certification, 2e 27
Hard Disk Installation (continued)

Figure 7-11: Specifying source file


location for a hard disk-based installation
Linux+ Guide to Linux Certification, 2e 28
Network-Based Installations

• Requires installation startup CD-ROM or bootable


USB flash memory drive
– Contains NIC drivers and programs allowing
connection to server
• Installation via one of following protocols:
– Network File System (NFS)
– File Transfer Protocol (FTP)
– Hypertext Transfer Protocol (HTTP)
• Must configure network settings

Linux+ Guide to Linux Certification, 2e 29


Network-Based Installations
(continued)

Figure 7-12: Configuring local network settings

Linux+ Guide to Linux Certification, 2e 30


Network-Based Installations
(continued)

Figure 7-13:Specifying source file


location for an NFS-based installation
Linux+ Guide to Linux Certification, 2e 31
Network-Based Installations
(continued)

Figure 7-14: Specifying source file


location for an FTP-based installation
Linux+ Guide to Linux Certification, 2e 32
Network-Based Installations
(continued)

Figure 7-15: Specifying source file


location for an HTTP-based installation
Linux+ Guide to Linux Certification, 2e 33
Automating Linux Installations

• Deploy several Linux servers and workstations


requiring same configuration
• Disk imaging software: Duplicates HDD contents
from one computer to another
– e.g., Symantec Ghost
– Typically loaded from boot floppy disk
– Copy whole partitions or HDDs to other HDDs
• Locally or across network

Linux+ Guide to Linux Certification, 2e 34


Automating Linux Installations
(continued)

Figure 7-16: Symantec Ghost


Linux+ Guide to Linux Certification, 2e 35
Automating Linux Installations
(continued)

• Kickstart file: Automated installation script


– Specifies normal OS installation choices
– ks.cfg
• Kickstart Configuration: Configure a new kickstart
file
• To use ks.cfg:
– Format floppy with ext2, copy ks.cfg to it
– Boot from installation startup CD-ROM
– At welcome screen, specify ks.cfg file

Linux+ Guide to Linux Certification, 2e 36


Automating Linux Installations
(continued)

Figure 7-17: The Kickstart Configurator


Linux+ Guide to Linux Certification, 2e 37
Troubleshooting Installation

• Computers typically have different BIOS


configurations
– Installing on different computers is rarely the same
• Problems primarily related to hardware support or
configuration
– Typically fixed by changing hardware configuration

Linux+ Guide to Linux Certification, 2e 38


Problems Starting the Installation

• Check BIOS boot order


• Check BIOS for reserved peripheral configurations
(IRQ, I/O addresses, DMA)

Linux+ Guide to Linux Certification, 2e 39


Problems During Installation

• For graphical installation, video card must be


detected
– Appropriate drivers must be loaded
– Video card may not be supported by mode and
resolution of graphical installation
• Use Linux nofb or linux lowres installation
• Mouse does not work
– Use text-based installation

Linux+ Guide to Linux Certification, 2e 40


Problems During Installation
(continued)

• Installation freezes
– Disable PnP support in BIOS prior to installation
• Installation ends abnormally
– “fatal signal 11” error displayed
– Could be problem with RAM
– Often fixed by turning off CPU cache memory or
increasing number of wait states in the BIOS
– Could also be RAM or CPU voltage issue

Linux+ Guide to Linux Certification, 2e 41


Problems During Installation
(continued)

• Other failure causes include bad memory chips, an


AMD K6 processor, laptop power management
conflicts, overclocked CPUs
• Overclocked: Running a processor at a higher
speed than it is rated for
– May lead to increased performance
– Produces more heat on processor
• May result in computer crashes

Linux+ Guide to Linux Certification, 2e 42


Problems After Installation

• May have problems if installation program did not


detect computer hardware properly or certain
programs were not installed
• Installation log file: Records actions that occur or
fail during installation
– /root/install.log: Lists packages installed
– /root/install.log.syslog: Lists all system events that
occurred during installation

Linux+ Guide to Linux Certification, 2e 43


Problems After Installation (continued)

• To verify hardware settings, examine contents of


/proc directory or boot-up log files
• To view hardware detected at boot time, use
dmesg command

Linux+ Guide to Linux Certification, 2e 44


Problems After Installation (continued)

Table 7-5: Files commonly found in the /proc directory


Linux+ Guide to Linux Certification, 2e 45
Problems After Installation (continued)

Table 7-5 (continued): Files commonly found in the /proc directory


Linux+ Guide to Linux Certification, 2e 46
Summary

• SCSI HDDs are uniquely identified by a SCSI ID


and attach to a controller via a terminated cable
• Each peripheral device must be configured with an
IRQ and I/O address prior to use, and can
optionally use a DMA channel
• Portable laptop computers typically use APM or
ACPI to shut down power to peripheral devices
when not in use to save battery power

Linux+ Guide to Linux Certification, 2e 47


Summary (continued)

• Computers that require fault tolerance typically


employ SCSI hard disks configured using RAID
• Linux can be installed using files located on DVD,
hard disks, and NFS, FTP, and HTTP servers
• Use disk imaging software or a kickstart file to
simplify the installation of Linux on several
computers

Linux+ Guide to Linux Certification, 2e 48


Summary (continued)

• Unsupported video cards, overclocked CPUs, PnP


support, and improper RAM settings can cause an
installation to fail
• The /proc directory contains information regarding
detected hardware on the system and is useful
when verifying whether an installation was
successful

Linux+ Guide to Linux Certification, 2e 49


Linux+ Guide to Linux
Certification, Second Edition

Chapter 8
Working with the BASH Shell
Objectives

• Redirect the input and output of a command


• Identify and manipulate common shell environment
variables
• Create and export new shell variables
• Edit environment files to create variables upon
shell startup

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Describe the purpose and nature of shell scripts


• Create and execute basic shell scripts
• Effectively use common decision constructs in shell
scripts

Linux+ Guide to Linux Certification, 2e 3


Command Input and Output

• BASH shell responsible for:


– Providing user interface
– Interpreting commands
– Manipulating command input and output
• Provided user specifies certain shell metacharacters
with command
• File descriptors: Numeric labels that define
command input and command output

Linux+ Guide to Linux Certification, 2e 4


Command Input and Output
(continued)

• Standard Input (stdin): File descriptor representing


command input
• Standard Output (stdout): File descriptor
representing command output
• Standard Error (stderror): File descriptor
representing command error messages

Linux+ Guide to Linux Certification, 2e 5


Command Input and Output
(continued)

Figure 8-1: The three common file descriptors

Linux+ Guide to Linux Certification, 2e 6


Redirection

• Redirect stdout and stderr from terminal screen to


a file
– Use “>” shell metacharacter
– Can redirect stdout and stderr to separate files
• Use separate filenames for stdout and stderr

Linux+ Guide to Linux Certification, 2e 7


Redirection (continued)

• Redirecting stdin to a file:


– Use “<“ shell metacharacter
• tr command: Replace characters in a file sent via
stdin

Linux+ Guide to Linux Certification, 2e 8


Redirection (continued)

Table 8-1: Common redirection examples


Linux+ Guide to Linux Certification, 2e 9
Pipes

• Send stdout of one command to another command


as stdin
• Pipe: String of commands connected by “|”
metacharacters
– stdout on left, stdin on right
• Commonly used to reduce amount of information
displayed on terminal screen

Linux+ Guide to Linux Certification, 2e 10


Pipes (continued)

Figure 8-2: Piping information from one command to another

Linux+ Guide to Linux Certification, 2e 11


Pipes (continued)

• Can use multiple pipes on command line


– Pass information from one command to another over
a series of commands
• filter commands: Commands that can take from
stdin and give to stdout
– Can be on either side of a pipe
• tee commands: Filter commands that also send
information to a file

Linux+ Guide to Linux Certification, 2e 12


Pipes (continued)

Figure 8-3: Piping several commands

Linux+ Guide to Linux Certification, 2e 13


Pipes (continued)

Table 8-2: Common filter commands

Linux+ Guide to Linux Certification, 2e 14


Pipes (continued)

• Can combine redirection and piping


– Input redirection must occur at beginning of pipe
– Output redirection must occur at end of pipe
• sed filter command: Search for and replace text
strings
• awk filter command: Search for text and perform
specified action on it

Linux+ Guide to Linux Certification, 2e 15


Shell Variables

• Variable: A reserved portion of memory containing


accessible information
• BASH shell has several variables in memory
• Environment variables: Contain information that
system and programs access regularly
• User-defined variables: Custom variables define by
users
• Special variables
– Useful when executing commands and creating new
files and directories

Linux+ Guide to Linux Certification, 2e 16


Environment Variables

• set command: Lists environment variables and


current values
• echo command: View contents a specified variable
– Use $ shell metacharacter
• Changing value of a variable:
– Specify variable name followed by equal sign (=) and
new value

Linux+ Guide to Linux Certification, 2e 17


Environment Variables (continued)

Table 8-3: Common BASH environment variables

Linux+ Guide to Linux Certification, 2e 18


Environment Variables (continued)

Table 8-3 (continued): Common BASH environment variables

Linux+ Guide to Linux Certification, 2e 19


Environment Variables (continued)

Table 8-3 (continued): Common BASH environment variables

Linux+ Guide to Linux Certification, 2e 20


User-Defined Variables

• Variable identifier: Name of a variable


• Creating new variables:
– Specify variable identifier followed by equal sign and
the new contents
• Features of variable identifiers:
– Can contain alphanumeric characters, dash
characters, or underscore characters
– Must not start with a number
– Typically capitalized to follow convention

Linux+ Guide to Linux Certification, 2e 21


User-Defined Variables (continued)

• Subshell: Shell created by current shell


– Most shell commands run in a subshell
– Variables created in current shell are not available to
subshells
• export command: Exports user-defined variables to
subshells
– Ensures that programs started by current shell have
access to variables
• env command: Lists all exported environment and
user-defined variables in a shell

Linux+ Guide to Linux Certification, 2e 22


Other Variables

• Not displayed by set or env commands


– Perform specialized functions in the shell
– e.g., UMASK variable
• alias command: Creates shortcuts to commands
– Use unique alias names
– Aliases stored in special variables
– Can create single alias to multiple commands
• Use ; metacharacter

Linux+ Guide to Linux Certification, 2e 23


Environment Files

• When exiting BASH shell, all stored variables are


destroyed
• Environment files: Store variables and values
– Executed each time BASH shell is started
– Ensures variables are always accessible

Linux+ Guide to Linux Certification, 2e 24


Environment Files (continued)

• Common BASH shell environment files (in order


they are executed):
– /etc/profile
– ~/.bash_profile
– ~/.bash_login
– ~/.profile
• Hidden environment files allow users to set
customized variables

Linux+ Guide to Linux Certification, 2e 25


Environment Files (continued)

• To add a variable, add a line to environment file


– Use command line syntax
• Any command can be placed inside any
environment file
– e.g., alias creation
• .bashrc (BASH run-time configuration): First hidden
environment file executed at login

Linux+ Guide to Linux Certification, 2e 26


Shell Scripts

• Shell script: Text file containing a list of commands


or constructs for shell to execute
– May contain any command that can be entered on
command line
• Hashpling: First line in a shell script
– Defines which shell is used to interpret shell script
commands

Linux+ Guide to Linux Certification, 2e 27


Shell Scripts (continued)

• Executing shell scripts with read permission:


– Start another BASH shell, specify the shell script as
an argument
• Executing shell scripts with read/write permission:
– Executed like any executable program

Linux+ Guide to Linux Certification, 2e 28


Escape Sequences

• Character sequences having special meaning in


the echo command
– Prefixed by \ character
– Must use –e option in echo command

Linux+ Guide to Linux Certification, 2e 29


Escape Sequences (continued)

Table 8-4: Common echo escape sequences

Linux+ Guide to Linux Certification, 2e 30


Reading Standard Input

• Shell scripts may need input from user


– Input may be stored in a variable for later use
• read command: Takes user input from stdin
– Places in a variable specified by an argument to
read command

Linux+ Guide to Linux Certification, 2e 31


Decision Constructs

• Most common type of construct used in shell


scripts
• Alter flow of a program:
– Based on whether a command completed
successfully
– Based on user input

Linux+ Guide to Linux Certification, 2e 32


Decision Constructs (continued)

Figure 8-4: A sample decision construct

Linux+ Guide to Linux Certification, 2e 33


Decision Constructs (continued)

Figure 8-5: A sample decision construct

Linux+ Guide to Linux Certification, 2e 34


The if Construct

• Control flow of program based on true/false


decisions
• Syntax:

Linux+ Guide to Linux Certification, 2e 35


The if Construct (continued)

• Common rules governing if constructs:


– elif (else if) and else statements optional
– Unlimited number of elif statements
– do these commands section may consist of multiple
commands
• One per line
– do these commands section typically indented for
readability
– End of statement must be “if”
– this is true may be a command or test statement
Linux+ Guide to Linux Certification, 2e 36
The if Construct (continued)

• test statement: Used to test a condition


– Generates a true/false value
– Inside of square brackets ( [ … ] )
• Must have spaces after “[” and before “]”
• Special comparison operators:
– –o (OR)
– –a (AND)
– ! (NOT)

Linux+ Guide to Linux Certification, 2e 37


The if Construct (continued)

Table 8-5: Common test statements

Linux+ Guide to Linux Certification, 2e 38


The if Construct (continued)

Table 8-6: Special operators in test statements

Linux+ Guide to Linux Certification, 2e 39


The case Construct

• Compares value of a variable with several


different patterns of text or numbers
• Syntax:

Linux+ Guide to Linux Certification, 2e 40


The case Construct (continued)

• If a match is found, commands to right of pattern


are executed
• Must end with esac

Linux+ Guide to Linux Certification, 2e 41


The && and || Constructs

• Time-saving shortcut constructs


– When only one decision needs to be made during
execution
• Syntax:
– command && command
– command || command

Linux+ Guide to Linux Certification, 2e 42


The && and || Constructs (continued)

• &&: Second command executed only if first


completes successfully
• ||: Second command executed only if first fails

Linux+ Guide to Linux Certification, 2e 43


Summary

• Three components are available to commands:


Standard Input, Standard Output, and Standard
Error
• Standard Input is typically user input taken from the
keyboard; Standard Output and Standard Error are
sent to the terminal screen
• You can redirect the Standard Output and
Standard Error of a command to a file using
redirection symbols

Linux+ Guide to Linux Certification, 2e 44


Summary (continued)

• Use the pipe symbol to redirect the Standard


Output from one command to the Standard Input of
another
• Most variables available to the BASH shell are
environment variables that are loaded into memory
after login from environment files
• You can create your own variables in the BASH
shell and export them so that they are available to
programs started by the shell

Linux+ Guide to Linux Certification, 2e 45


Summary (continued)

• The UMASK variable and command aliases are


special variables that must be set using a certain
command
• Shell scripts can be used to execute several Linux
commands
• Decision constructs can be used in shell scripts to
execute certain Linux commands based on user
input or the results of a certain command

Linux+ Guide to Linux Certification, 2e 46


Linux+ Guide to Linux
Certification, Second Edition

Chapter 9
System Initialization
and X Windows
Objectives

• Summarize the major steps necessary to boot a


Linux system
• Configure the LILO and GRUB boot loaders
• Dual boot Linux with the Windows OS using LILO,
GRUB, and NTLOADER
• Understand how the init daemon initializes the
system at boot time into different runlevels

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Configure the system to start daemons upon


system startup
• Explain the purpose of the major Linux GUI
components: X Windows, Window Manager, and
desktop environment
• List common Window Managers and desktop
environments used in Linux
• Configure X Windows settings using various Linux
utilities

Linux+ Guide to Linux Certification, 2e 3


The Boot Process

• POST: Series of tests run when computer is turned


on
– Ensures functionality of hardware
• MBR: Defines partitions and boot loader
– Normally located on first HDD sector
• Boot loader: Program used to load an OS
• MBR might contain pointer to a partition containing
a boot loader on the first sector
• Active partition: Partition pointed to by MBR
– One per HDD
Linux+ Guide to Linux Certification, 2e 4
The Boot Process (continued)

• /boot: Directory containing kernel and boot-related


files
• Vmlinuz-<kernel version>: Linux kernel file
• Daemon: System process that performs useful
tasks
– e.g., printing, scheduling, OS maintenance
• Init (initialize) daemon: First process started by
Linux kernel
– Loads all other daemons
– Brings system to usable state

Linux+ Guide to Linux Certification, 2e 5


The Boot Process (continued)

Figure 9-1: The boot process

Linux+ Guide to Linux Certification, 2e 6


Boot Loaders

• Primary function: Load Linux kernel into memory


• Other functions:
– Passing information to kernel
– Booting another OS
• Two most common boot loaders:
– Linux Loader (LILO)
– GRand Unified Boot loader (GRUB)

Linux+ Guide to Linux Certification, 2e 7


LILO

• Traditional Linux boot loader


• Typically located on MBR
• Allows choice of OS to load at startup
• To configure, edit /etc/lilo.conf

Linux+ Guide to Linux Certification, 2e 8


LILO (continued)

• append= keyword (in /etc/lilo.conf): Useful for


manually passing information to Linux kernel
– Can pass almost any hardware information
• Format is hardware dependent
• Must reinstall LILO if /etc/lilo.conf file altered
• lilo command: Reinstalls LILO
– -u option: Uninstall LILO

Linux+ Guide to Linux Certification, 2e 9


GRUB
• More recent than the LILO boot loader
• Stage 1: First major part of GRUB
– Typically resides on MBR
– Points to Stage 1.5
• Stage1.5: Loads filesystem support
– Resides in /boot/grub
• Stage2: Performs boot loader functions
– Displays graphical boot loader screen
• To configure, edit /boot/grub/grub.conf
– Read directly by Stage 2 boot loader
– HDDs and partitions identified by numbers
• Format: (hd<drive#>,<partition#>)
Linux+ Guide to Linux Certification, 2e 10
GRUB (continued)

Figure 9-3: GRUB boot loader screen


Linux+ Guide to Linux Certification, 2e 11
GRUB (continued)

• GRUB root partition: Partition containing Stage 2


boot loader and grub.conf file
• GRUB normally allows manipulation of boot loader
– To prevent, enable password protection
• grub-md5-crypt command: Generates encrypted
password for use in grub.conf file
• Can switch boot loader from GRUB to LILO at any
time
• grub-install command: Installs GRUB boot loader

Linux+ Guide to Linux Certification, 2e 12


GRUB (continued)

Figure 9-4: Viewing help at the GRUB boot loader screen prompt
Linux+ Guide to Linux Certification, 2e 13
Dual Booting Linux

• Only one OS may be used at a time


• Boot loader may be configured to allow choice of
OS at boot time

Linux+ Guide to Linux Certification, 2e 14


Using LILO or GRUB to Dual Boot
other Operating Systems

• Dual boot: Two or more OSs exist on HDD


• Easiest if Linux installed after another OS
– Allows installation program to detect other OS
• Place appropriate entries in boot loader configuration
file
• LILO and GRUB cannot load Windows Kernel
directly

Linux+ Guide to Linux Certification, 2e 15


Using LILO or GRUB to Dual Boot
other Operating Systems (continued)

Figure 9-5: Partitioning for a dual boot system


Linux+ Guide to Linux Certification, 2e 16
Using LILO or GRUB to Dual Boot
other Operating Systems (continued)

Figure 9-6: Configuring GRUB for a dual boot system


Linux+ Guide to Linux Certification, 2e 17
Using FIPS

• Windows installers use entire HDD for Windows


partitions
– Leaves no space for Linux
• First non-destructive Interactive Partition Splitter
(FIPS): Resizes Windows partition
– Preserves Windows OS on Windows partition
– Creates space to install Linux

Linux+ Guide to Linux Certification, 2e 18


Using FIPS (continued)

• Guidelines/limitations to using FIPS:


– FAT16 and FAT32 filesystems only
– Will only work with primary Windows partition
– Windows partition split into two primary partitions
– Need sufficient free space within existing Windows
partition to allow Linux installation

Linux+ Guide to Linux Certification, 2e 19


Using a Windows Boot Loader to Dual
Boot Linux
• Specify location of GRUB or LILO in Windows boot
loader configuration
• NTLOADER: Boot loader available with Windows
NT/2000/XP
– At boot time, prompts for OS to boot
– Able to load LILO or GRUB
• Windows must be installed on first primary active
partition
– NTLOADER placed on MBR by default

Linux+ Guide to Linux Certification, 2e 20


Using a Windows Boot Loader to Dual
Boot Linux (continued)

Figure 9-7: Configuring GRUB to reside on a Linux partition


Linux+ Guide to Linux Certification, 2e 21
Using a Windows Boot Loader to Dual
Boot Linux (continued)
• When Linux installed, install GRUB on first sector
of the partition
– Avoids overwriting NTLOADER in MBR
• After Linux installed:
– Run Linux rescue utility
– Make GRUB bootable image file (linboot.bin)
– Reboot into Windows OS
– Copy linboot.bin to C:\
– Configure NTLOADER configuration file

Linux+ Guide to Linux Certification, 2e 22


Using a Windows Boot Loader to Dual
Boot Linux (continued)

• Boot.ini: File used to configure NTLOADER


• For NTLOADER to be able to boot Linux, must
specify the path to linboot.bin

Linux+ Guide to Linux Certification, 2e 23


Using a Windows Boot Loader to Dual
Boot Linux (continued)

Figure 9-8: NTLOADER operating


system choice screen at boot time
Linux+ Guide to Linux Certification, 2e 24
Linux Initialization

• Kernel assumes control after Linux loaded


– Executes first daemon process (init daemon)
• /etc/inittab: Configuration file for init daemon

Linux+ Guide to Linux Certification, 2e 25


Runlevels

• Runlevel: Defines number and type of daemons


loaded into memory and executed
– init daemon responsible for changing runlevels
• Often called initstates
• runlevel command: Displays current and most
recent runlevel
• init command: Change OS runlevel
• telinit command: Alias to init command

Linux+ Guide to Linux Certification, 2e 26


The /etc/inittab File

• Consulted to start or stop daemons


• /etc/rc.d/rc.sysinit: First script executed during
system startup
– Init hardware, set variables, check filesystems,
perform system tasks for daemon loading
• mingetty program: Displays login prompt on
character-based terminals
• /etc/rc.d/rc.local file: Performs post-system-startup
tasks

Linux+ Guide to Linux Certification, 2e 27


The /etc/inittab File (continued)

• /etc/rc.d/rc command: Executes all files starting


with S or K in /etc/rc.d/rc*.d/
– Runlevel must be specified
• e.g., /etc/rc.d/rc 5 will execute files in /etc/rc.d/rc5.d/
– Symbolic links to scripts that start daemons
– S means “Start,” K means “Kill”

Linux+ Guide to Linux Certification, 2e 28


The /etc/inittab File (continued)

Figure 9-9: The Linux initialization process

Linux+ Guide to Linux Certification, 2e 29


Configuring Daemon Startup

• Most symbolic links in /etc/rc.d/rc*.d point to


daemon executable files in /etc/rc.d/init.d
• Most daemons accept arguments start, stop,
restart
• To add daemons to be automatically started:
– Add executable to /etc/rc.d/init.d
– Create appropriate links to /etc/rc.d/rc*.d
• ntsysv utility: Modifies file entries in /etc/rc.d/rc*.d
directories

Linux+ Guide to Linux Certification, 2e 30


Configuring Daemon Startup
(continued)

Figure 9-10: Results of ntsysv―level 5 command


Linux+ Guide to Linux Certification, 2e 31
The X Windows System: Linux GUI
Components

Figure 9-11: Components of the Linux GUI


Linux+ Guide to Linux Certification, 2e 32
X Windows

• X Windows: Core component of Linux GUI


• X client: Requests graphics from X server and
displays them
– Does not need to run on same computer as X
Windows
• X server: Draws graphics
• XFree86: OSS version of X Windows
– Originally intended for Intelx86 platform

Linux+ Guide to Linux Certification, 2e 33


Windows Managers and Desktop
Environments

• Window manager: Modifies look and feel of X


Windows
• Desktop environment: Works with a window
manager to provide standard GUI environment
– Uses standard programs and development tools
– KDE and GNOME are most common

Linux+ Guide to Linux Certification, 2e 34


Windows Managers and Desktop
Environments (continued)

• K Windows Manager (kwm): Window manager that


works under KDE
• Qt toolkit: Software toolkit used with KDE
• GNOME Desktop Environment: Default desktop
environment in Red Hat Linux
– Sawfish Window Manager
– GTK+ toolkit
• Xfce Desktop Environment: Consumes less
hardware resources than KDE or GNOME

Linux+ Guide to Linux Certification, 2e 35


Windows Managers and Desktop
Environments (continued)

Figure 9-12: The KDE desktop


Linux+ Guide to Linux Certification, 2e 36
Windows Managers and Desktop
Environments (continued)

Figure 9-13: The GNOME desktop


Linux+ Guide to Linux Certification, 2e 37
Windows Managers and Desktop
Environments (continued)

Figure 9-14: The Xfce desktop


Linux+ Guide to Linux Certification, 2e 38
Windows Managers and Desktop
Environments (continued)

Figure 9-15: The Tab Window Manager


Linux+ Guide to Linux Certification, 2e 39
Starting and Stopping X Windows

• runlevel 5 starts gdm


– Displays graphical login screen
– Allows user to choose the desktop environment or
Window Manager
• /etc/X11/gdm/gdm.conf: Contains gdm
configuration data
• For runlevel 3:
– Start gdm manually
– Or, use startx command

Linux+ Guide to Linux Certification, 2e 40


Starting and Stopping X Windows
(continued)

Figure 9-16: The GNOME Display Manager


Linux+ Guide to Linux Certification, 2e 41
Starting and Stopping X Windows
(continued)

• startx command: start X Windows and Window


Manager or desktop environment specified in
.Xclients file in home directory
– Usually points to .Xclients-default file
• Edit .Xclients-defaults file to start other desktops or
Window Managers on X Windows
• Desktop Switching Tool: Change settings used in
the .Xclients-default file from KDE or GNOME

Linux+ Guide to Linux Certification, 2e 42


Starting and Stopping X Windows
(continued)

Figure 9-17: The Desktop Switching Tool


Linux+ Guide to Linux Certification, 2e 43
Configuring X Windows
• X Windows interfaces with video hardware
– Requires information regarding keyboard, mouse,
monitor, and video adapter card
• Required video adapter card information:
– Model
– Amount of RAM
– Chipset
• Required monitor information:
– Maximum resolution supported
– Horizontal sync (hsync) range
– Vertical sync (vsync) range

Linux+ Guide to Linux Certification, 2e 44


Configuring X Windows (continued)

• Mouse, keyboard, monitor, and video adapter card


information stored in a file
– /etc/X11/xorg.conf: X.org implementation of X
Windows
– /etc/X11/XF86Config: XFree86 implementation of X
Windows
• mouseconfig and system-config-mouse
commands: Configure mouse

Linux+ Guide to Linux Certification, 2e 45


Configuring X Windows (continued)

Figure 9-18: Mouse configuration using mouseconfig


Linux+ Guide to Linux Certification, 2e 46
Configuring X Windows (continued)

• system-config-keyboard command: Configure


keyboard
• system-config-display command: Configure video
adapter card and monitor
• xvidtune utility: Fine-tune the vsync and hsync of
the video card

Linux+ Guide to Linux Certification, 2e 47


Configuring X Windows (continued)

Figure 9-19: Keyboard configuration using system-config-keyboard


Linux+ Guide to Linux Certification, 2e 48
Configuring X Windows (continued)

Figure 9-20: Configuring resolution and


color depth using system-config-display
Linux+ Guide to Linux Certification, 2e 49
Configuring X Windows (continued)

Figure 9-21: Configuring video card and monitor


hardware using system-config-display
Linux+ Guide to Linux Certification, 2e 50
Configuring X Windows (continued)

Figure 9-23: The xvidtune utility


Linux+ Guide to Linux Certification, 2e 51
Summary
• Boot loaders are typically loaded by the system
BIOS from the MBR or the first sector of the active
partition of a hard disk
• The boot loader is responsible for loading the Linux
kernel
• The LILO boot loader uses the /etc/lilo.conf
configuration file; GRUB boot loader uses the
/boot/grub/grub.conf configuration file
• Can use the LILO or GRUB boot loader to dual
boot Linux and the Windows OS
• The FIPS utility splits a FAT or FAT32 partition to
create enough space to install Linux

Linux+ Guide to Linux Certification, 2e 52


Summary (continued)
• Seven standard runlevels are used to categorize a
Linux system based on the number and type of
daemons loaded in memory
• The init daemon is responsible for loading daemons
using its configuration file /etc/inittab
• Daemons are typically stored in the /etc/rc.d/init.d
directory and loaded at system startup from entries
in the /etc/rc.d/rc*.d directories
• The Linux GUI has several interchangeable
components: X server, X clients, Window Manager,
and optional desktop environment
Linux+ Guide to Linux Certification, 2e 53
Summary (continued)

• X Windows is the core component of the Linux GUI


that draws graphics to the terminal screen
• You can start the Linux GUI from runlevel 3 by
typing startx at a command prompt, or from
runlevel 5 by using the gdm
• The system-config-mouse, mouseconfig, system-
config-keyboard, system-config-display, and
xvidtune utilities can be used to configure the
hardware settings used by X Windows

Linux+ Guide to Linux Certification, 2e 54


Linux+ Guide to Linux
Certification, Second Edition

Chapter 11
Common Administrative
Tasks
Objectives

• Set up, manage, and print to printers on a Linux


system
• Understand the purpose of log files and how they
are administered
• Create, modify, manage, and delete user and
group accounts using command-line and graphical
utilities

Linux+ Guide to Linux Certification, 2e 2


Printer Administration: The Common
UNIX Printing System

• Common Unix Printing System (CUPS): Most


common printing system used on Linux
• Print job: Set of information sent to a printer
– File, set of files, output of a command
• lp command: Sends a print job to a printer

Linux+ Guide to Linux Certification, 2e 3


Printer Administration: The Common
UNIX Printing System (continued)

• cups daemon (cupsd): Responsible for printing in


CUPS printing system
• Print job ID: Print job’s unique identifier
• Print queue: Directory holding print jobs waiting to
be printed
– Typically /var/spool/cups

Linux+ Guide to Linux Certification, 2e 4


Printer Administration: The Common
UNIX Printing System (continued)

• Printer can accept or reject request to print


– If rejected, CUPS gives an error message
• Spooling or queuing: Accepting print jobs into a
print queue
• Printing: Sending print jobs from print queue to a
printer

Linux+ Guide to Linux Certification, 2e 5


Printer Administration: The Common
UNIX Printing System (continued)

• lpstat command: With –t (total) option, lists all


printers and their status
• accept, reject, enable, and disable commands:
Manipulate status of a printer
– For enable, must specify full path enable command
(/usr/bin/enable)

Linux+ Guide to Linux Certification, 2e 6


Printer Administration: The Common
UNIX Printing System (continued)

Figure 11-1: The print process

Linux+ Guide to Linux Certification, 2e 7


Managing Print Jobs

• lp –d command: Print to a specified printer


– If –d option omitted, prints to default printer
• lpoptions –d command: Set default printer
• Users can set own default printer
– Add to .lpoptions file in home directory

Linux+ Guide to Linux Certification, 2e 8


Managing Print Jobs (continued)

• lp command accepts information from stdin


• lpstat command can list print jobs in queue for a
printer
• cancel command: Remove print jobs from print
queue
• lpadmin command: Perform printer administration
– e.g., restrict who can print to specific printers

Linux+ Guide to Linux Certification, 2e 9


Managing Print Jobs (continued)

Table 11-1: Common options to the lp command

Linux+ Guide to Linux Certification, 2e 10


Managing Print Jobs (continued)

Table 11-2: Common options to the lpstat command

Linux+ Guide to Linux Certification, 2e 11


The LPD Printing System

• Line Printer Daemon (LPD): Printing system used


on older Linux systems
• lpr command: Create print jobs in print queue
• lpc command: View status of printers
• lpq command: View print jobs in print queue
• lprm command: Remove print jobs

Linux+ Guide to Linux Certification, 2e 12


Configuring Printers

• /etc/cups/cupsd.conf: Contains cupsd settings


• /etc/cups/printers.conf: Contains each printer’s
configuration information
• Printer Configuration tool: Used to configure
printers
– e.g., Add new printers
– Configures queue, not printer

Linux+ Guide to Linux Certification, 2e 13


Configuring Printers (continued)

Figure 11-2: The Printer Configuration tool

Linux+ Guide to Linux Certification, 2e 14


Configuring Printers (continued)

Figure 11-3: Specifying the name of a new printer

Linux+ Guide to Linux Certification, 2e 15


Configuring Printers (continued)

Figure 11-5: Different queue types available for a new printer

Linux+ Guide to Linux Certification, 2e 16


Configuring Printers (continued)

• For local printers, must choose printer port


– Such as /dev/lp0
• For remote printers, specify name or IP address of
remote server, printer name, or printer port
• Enable sharing as needed
– CUPS can automatically search for other shared
CUPS printers
• Allow remote computers to print using the LPD
protocol

Linux+ Guide to Linux Certification, 2e 17


Configuring Printers (continued)

Figure 11-6: Selecting the printer model for a new printer

Linux+ Guide to Linux Certification, 2e 18


Configuring Printers (continued)

Figure 11-7: Completing the creation of a new printer

Linux+ Guide to Linux Certification, 2e 19


Configuring Printers (continued)

Figure 11-8: View a configured printer

Linux+ Guide to Linux Certification, 2e 20


Configuring Printers (continued)

Figure 11-9: Sharing a printer to network users

Linux+ Guide to Linux Certification, 2e 21


Configuring Printers (continued)

Figure 11-10: Specifying shared printer options

Linux+ Guide to Linux Certification, 2e 22


Log File Administration

• Log file: File containing system information


• /var/log: Contains most log files
– Many programs store log files in subdirectories

Linux+ Guide to Linux Certification, 2e 23


Log File Administration (continued)

Table 11-3: Common Linux log files found in /var/log


Linux+ Guide to Linux Certification, 2e 24
The System Log Daemon

• System log daemon (syslogd): Logs system events


– Uses /etc/syslog.conf file
• Entries indicate what information to write to what log
file

Linux+ Guide to Linux Certification, 2e 25


The System Log Daemon (continued)

• Facility: Area of system that information is gathered


from
• Priority: Importance of system information

Linux+ Guide to Linux Certification, 2e 26


The System Log Daemon (continued)

Table 11-4: Facilities used by the System Log Daemon


Linux+ Guide to Linux Certification, 2e 27
The System Log Daemon (continued)

Table 11-5: Priorities used by the log daemon


Linux+ Guide to Linux Certification, 2e 28
Managing Log Files

• Log files can take up unnecessary space


– Clear contents occasionally
• Print copy for records
• Use > redirection symbol
• Do not remove log files
– Permissions and ownership will be removed

Linux+ Guide to Linux Certification, 2e 29


Managing Log Files (continued)

• logrotate command: Back up and clear log files


• /etc/logrotate.conf: Used by logrotate utility
– Specifies rotation parameters for log files
• Log files compressed after rotation

Linux+ Guide to Linux Certification, 2e 30


Administering Users and Groups

• Authentication: Verify user’s identity


– Compare username and password to system
database
• Database containing user account information
typically consists of two files:
– /etc/passwd: User account information
• Previously stored password information
– /etc/shadow: Encrypted password information
• pwconv command: Convert system to use an
/etc/shadow file for encrypted password storage

Linux+ Guide to Linux Certification, 2e 31


Administering Users and Groups
(continued)

• pwunconv command: Revert back to using an


/etc/passwd file only
• User Identifier (UID): Unique user ID for a user
• Group Identifier (GID): Primary group ID for each
user
• Primary group: Group owner for all files created by
a user
– Specified in /etc/passwd file

Linux+ Guide to Linux Certification, 2e 32


Administering Users and Groups
(continued)

• General Electric Comprehensive Operating System


(GECOS): Field in /etc/passwd file containing user
account description
• Root user usually listed at top of /etc/passwd file
• /etc/shadow: Password field contains encrypted
password
• /etc/passwd: Password field contains an x (not
used)

Linux+ Guide to Linux Certification, 2e 33


Administering Users and Groups
(continued)

• Passwords often set to expire at certain intervals


– Intervals specified in /etc/shadow
• /etc/group file: Lists all groups and their members
– Allows users to belong to multiple groups
– Password field usually contains an x

Linux+ Guide to Linux Certification, 2e 34


Creating User Accounts

• useradd command: Add new user accounts


• Most new user information comes from two files:
– /etc/login.defs:
• E-mail location, password expiration, minimum
password length, range of UIDs and GIDs
– /etc/default/useradd:
• default primary group, home directory location,
password expiration info, shell, skeleton directory

Linux+ Guide to Linux Certification, 2e 35


Creating User Accounts (continued)

• Skeleton directory: Contains files to copy to new


users’ home directories
– Usually /etc/skel
– Mostly environment files
• passwd command: Set a user’s password
– If no arguments, sets current user’s password
– User accounts must have password set to log on
– Root user can change any user’s password

Linux+ Guide to Linux Certification, 2e 36


Creating User Accounts (continued)

Table 11-6: Common options to the useradd command


Linux+ Guide to Linux Certification, 2e 37
Modifying User Accounts

• usermod command: Modify user account


information
• chage command: Modify password expiration
information
• Locking an account: Make an account temporarily
unusable
– Alter password information
• chsh command: Change a valid shell to an invalid
shell

Linux+ Guide to Linux Certification, 2e 38


Modifying User Accounts (continued)

Table 11-7: Common options to the usermod command

Linux+ Guide to Linux Certification, 2e 39


Deleting User Accounts

• userdel command: Remove user accounts


• When an account is deleted, files previously owned
by the user become owned by a number
representing UID of deleted user
– Next user with that UID will own the files

Linux+ Guide to Linux Certification, 2e 40


Managing Groups

• groupadd command: Add a group to the system


• groupmod command: Modify GID name of a group
on the system
• groupdel command: Remove a group from the
system

Linux+ Guide to Linux Certification, 2e 41


Managing Groups (continued)

• groups command: List groups that a user belongs


to
• id command: List GIDs of groups that a user
belongs to
• newgrp command: Temporarily change user’s
primary group
• Graphical utilities exist to create, modify, and
delete user and group accounts

Linux+ Guide to Linux Certification, 2e 42


Managing Groups (continued)

Figure 11-11: Configure users and


groups with a desktop environment
Linux+ Guide to Linux Certification, 2e 43
Summary

• Print jobs are spooled to a print queue


• Can configure spooling or printing by using the
accept, reject, enable, and disable commands
• Print jobs are created using lp, can be viewed in
the queue using lpstat, and are removed from the
queue using cancel
• Create local and remote printers using Printer
Configuration or /etc/cups/printers.conf

Linux+ Guide to Linux Certification, 2e 44


Summary (continued)

• Most log files in Linux are stored in /var/log


• System events are typically logged to files by the
System Log Daemon
• Log files should be cleared or rotated over time to
save disk space
• User and group account information is typically in
/etc/passwd, /etc/shadow, and /etc/group
• Use the useradd command to create users and the
groupadd command to create groups

Linux+ Guide to Linux Certification, 2e 45


Summary (continued)

• All users must have a valid password before


logging in to a Linux system
• Users can be modified with usermod, chage, chsh,
and passwd commands, and groups can be
modified using groupmod command
• The userdel and groupdel commands remove
users and groups from the system, respectively

Linux+ Guide to Linux Certification, 2e 46


Linux+ Guide to Linux
Certification, Second Edition

Chapter 14
Network Configuration
Objectives

• Describe the purpose and types of networks,


protocols, and media access methods
• Understand the basic configuration of TCP/IP
• Configure a NIC interface to use TCP/IP

Linux+ Guide to Linux Certification, 2e 2


Objectives (continued)

• Configure a modem, ISDN, and DSL interface to


use PPP and TCP/IP
• Understand the purpose of host names and how
they are resolved to IP addresses
• Use common network utilities to interact with
network services

Linux+ Guide to Linux Certification, 2e 3


Networks and TCP/IP

• Network: Two or more computers joined via


network media and able to exchange information
• Local Area Networks (LANs): Computers within
close proximity
• Wide Area Networks (WANs): Computers
separated by large distances
• Internet service provider (ISP): Company providing
internet access

Linux+ Guide to Linux Certification, 2e 4


Networks and TCP/IP (continued)

• Routers: Devices capable of transferring packets


between networks
• Protocols: Set of rules for communication between
networked computers
• Packets: Packages of data formatted by a network
protocol
• Media access method: Defines how networked
computers share access to the physical medium

Linux+ Guide to Linux Certification, 2e 5


Networks and TCP/IP (continued)

• Linux network protocols:


– TCP/IP (Transfer Control Protocol/Internet Protocol)
– UDP/IP (User Datagram Protocol/Internet Protocol)
– IPX/SPX (Internetwork Packet Exchange/Sequence
Packet Exchange)
– Appletalk
– DLC (Data Link Control)
– DECnet (Digital Equipment Corporation network)

Linux+ Guide to Linux Certification, 2e 6


Networks and TCP/IP (continued)

• Ethernet: Most common network media access


method
• Token Ring: Popular media access method
• Media access method usually contained on NIC or
modem hardware

Linux+ Guide to Linux Certification, 2e 7


The TCP/IP Protocol:
IP Addresses

• IP address: Unique number that identifies a


networked computer
– Octets: Series of four 8-bit numbers
• Unicast: Directed TCP/IP communication between
two computers

Linux+ Guide to Linux Certification, 2e 8


The TCP/IP Protocol:
IP Addresses (continued)

• IP addresses composed of two parts:


– Network ID: Network computer is located on
– Host ID: Single computer on that network
• Cannot have two computers with same host ID on a
network
• Only computers with same network ID can
communicate without a router

Linux+ Guide to Linux Certification, 2e 9


Subnet Masks

• Define which part of IP address is the network ID


and which part is the host ID
– Series of four 8-bit numbers
• ANDing: Calculate network and host IDs from an IP
address and subnet mask
– Compare binary bits

Linux+ Guide to Linux Certification, 2e 10


Subnet Masks (continued)

Figure 14-1: A sample IP address and subnet mask


Linux+ Guide to Linux Certification, 2e 11
Subnet Masks (continued)

• 0.0.0.0 = all networks


• 255.255.255.255 = all computers
• 255 in an IP address can specify many hosts
– Broadcast addresses

Linux+ Guide to Linux Certification, 2e 12


Default Gateway

• IP address on router that sends packets to remote


networks
• Routers can distinguish between different networks
– Move packets between them
– Have assigned IP addresses on each attached
network

Linux+ Guide to Linux Certification, 2e 13


TCP/IP Classes and Subnetting

• IP address class defines default subnet mask of


associated device
• Multicast: TCP/IP communication destined for a
certain group of computers
– Class D addresses
• Subnetting: Divide a large network into smaller
networks
– Control traffic flow
– Take bits from host ID, give to network ID

Linux+ Guide to Linux Certification, 2e 14


TCP/IP Classes and Subnetting
(continued)

Table 14-1: IP address classes

Linux+ Guide to Linux Certification, 2e 15


Configuring a NIC Interface

• ifconfig command: Assign TCP/IP configuration to


a NIC
– Also used to view configuration of all network
interfaces in computer
• dhclient command: Receive TCP/IP configuration
from DHCP or Boot Protocol (BOOTP) server

Linux+ Guide to Linux Certification, 2e 16


Configuring a NIC Interface
(continued)

• /etc/sysconfig/network-scripts/ifcfg-<interface> file:
Stores NIC configurations
• Packet internet groper (ping) command: Check
TCP/IP connectivity on a network

Linux+ Guide to Linux Certification, 2e 17


Configuring a NIC Interface
(continued)

Figure 14-2: Configuring network interfaces


Linux+ Guide to Linux Certification, 2e 18
Configuring a NIC Interface
(continued)

Figure 14-3: Configuring TCP/IP information for a network interface


Linux+ Guide to Linux Certification, 2e 19
Configuring a PPP Interface

• Run TCP/IP over serial lines


– Use a WAN protocol
• Three common Point-to-Point Protocol (PPP)
technologies:
– Modems
– ISDN
– DSL

Linux+ Guide to Linux Certification, 2e 20


Configuring a PPP Interface
(continued)

Figure 14-4: Adding a network interface


Linux+ Guide to Linux Certification, 2e 21
Configuring a PPP Interface
(continued)

Figure 14-5: Selecting modem hardware


Linux+ Guide to Linux Certification, 2e 22
Configuring a PPP Interface
(continued)

Figure 14-6: Selecting ISDN hardware


Linux+ Guide to Linux Certification, 2e 23
Configuring a PPP Interface
(continued)

Figure 14-7: Specifying ISP settings


Linux+ Guide to Linux Certification, 2e 24
Configuring a PPP Interface
(continued)

• Information about PPP devices stored in files


named ifcfg-<InternetServiceProviderName>
– /etc/sysconfig/network-scripts directory
• Other configurations used by PPP daemon stored
in /etc/ppp and /etc/isdn

Linux+ Guide to Linux Certification, 2e 25


Configuring a PPP Interface
(continued)

Figure 14-8: Specifying TCP/IP settings


Linux+ Guide to Linux Certification, 2e 26
Configuring a PPP Interface
(continued)

Figure 14-9: Configuring an xDSL connection


Linux+ Guide to Linux Certification, 2e 27
Configuring a PPP Interface
(continued)

Figure 14-10: Activating a PPP connection


Linux+ Guide to Linux Certification, 2e 28
Name Resolution

• Hostnames: User-friendly computer name


• FQDN: Hostname following DNS convention
• DNS: Hierarchical namespace for host names
• hostname command: View or set a computer’s host
name

Linux+ Guide to Linux Certification, 2e 29


Name Resolution (continued)

Figure 14-11: The Domain Name Space


Linux+ Guide to Linux Certification, 2e 30
Name Resolution (continued)

• TCP/IP cannot identify computers via hostnames


– Must map hostnames to IP addresses
– Entries in /etc/hosts file
• ISPs list FQDNs in DNS servers on Internet
– Applications request IP addresses associated with
FQDN

Linux+ Guide to Linux Certification, 2e 31


Connecting to Network Resources

• Network resources:
– Shared printers
– Applications
– Files
• To use network resources, must have appropriate
network utilities

Linux+ Guide to Linux Certification, 2e 32


Downloading Files Using FTP

• Most web browsers have built-in FTP utility


• FTP utility: Downloads files from FTP servers

Linux+ Guide to Linux Certification, 2e 33


Downloading Files Using FTP
(continued)

Figure 14-12: Using a Web browser FTP client


Linux+ Guide to Linux Certification, 2e 34
Downloading Files Using FTP
(continued)

Table 14-2: Common FTP commands


Linux+ Guide to Linux Certification, 2e 35
Downloading Files Using FTP
(continued)

Table 14-2 (continued): Common FTP commands

Linux+ Guide to Linux Certification, 2e 36


Accessing Files with NFS

• NFS: Common method for file transfer between


UNIX and Linux computers
– Not as common as FTP
– Mount directory from a remote computer

Linux+ Guide to Linux Certification, 2e 37


Accessing Windows Files

• Mount shared Windows directory to local directory


– Filesystem must be smbfs
• smbmount command: Mount directories from
Windows computers
• smbclient utility: Connect to shares on a Windows
system
• umount command: Unmount Windows directories

Linux+ Guide to Linux Certification, 2e 38


Running Remote Applications

• Access to BASH shell may be obtained by


connecting to a server across a network
• telnet utility: Most common utility used to obtain
BASH shell over a network
– No encryption
• Secure Shell (ssh) utility: Uses encryption

Linux+ Guide to Linux Certification, 2e 39


Running Remote Applications
(continued)

• rlogin: Obtain a shell from remote computer on


network
• “r” utilities allow access to remote computers
without a password
• Trusted access: Computers allowed to access a
computer without providing a password

Linux+ Guide to Linux Certification, 2e 40


Accessing E-mail

• Post Office Protocol (POP): Download e-mail


messages from e-mail server
• Internet Message Access Protocol (IMAP): View e-
mail messages across network
• Simple Mail Transfer Protocol (SMTP): Sending
mail from MUA to e-mail server
– Mozilla Mail is most common MUA for Linux

Linux+ Guide to Linux Certification, 2e 41


Accessing E-mail (continued)

Figure 14-13: Configuring a mail account in Mozilla Mail


Linux+ Guide to Linux Certification, 2e 42
Accessing E-mail (continued)

Figure 14-14: Using Mozilla Mail


Linux+ Guide to Linux Certification, 2e 43
Accessing E-mail (continued)

• Linux systems typically use an internal mail system


designed for administration
– Daemons e-mail root user when important events or
problems occur
• mail utility: Basic e-mail reader available on most
Linux distributions
• mutt utility: Popular MUA
– Can run in a terminal

Linux+ Guide to Linux Certification, 2e 44


Accessing E-mail (continued)

Figure 14-15: The mutt mail user agent


Linux+ Guide to Linux Certification, 2e 45
Summary

• A network is a collection of computers that are


connected together and share information
• Protocols define the format of information that is
transmitted across a network
• The protocol used by the Internet and most
networks is TCP/IP
• Each computer on a TCP/IP network must have a
valid IP address and subnet mask

Linux+ Guide to Linux Certification, 2e 46


Summary (continued)

• The /etc/sysconfig/network-scripts directory


contains the configuration for NIC and PPP
interfaces
• The TCP/IP configuration of a network interface
can be specified manually or obtained
automatically from a DHCP or BOOTP server
• Host names are used to easily identify computers
on a network; host names that follow the DNS are
FQDNs

Linux+ Guide to Linux Certification, 2e 47


Summary (continued)

• Host names must be resolved to an IP address


before network communication can take place
• Files, applications, and e-mail can be accessed
across the network with the appropriate network
utility

Linux+ Guide to Linux Certification, 2e 48


Linux+ Guide to Linux
Certification, Second Edition

Chapter 15
Configuring Network Services
and Security
Objectives

• Identify and configure common network services


• Configure routing and firewalls
• Describe the different facets of Linux security
• Increase the security of a Linux computer
• Outline measures that can be used to detect a
Linux security breach

Linux+ Guide to Linux Certification, 2e 2


Network Services

• Processes that provide some type of valuable


service for client computers on network
• Must identify types and features of network
services before they can be configured
• Important to configure network-related services,
such as routing and firewalls

Linux+ Guide to Linux Certification, 2e 3


Identifying Network Services

• Port: Number uniquely identifying a network service


– Ensure that packets delivered to proper service
– Range from 0 to 65534
• /etc/services file: Lists ports and associated
protocol
• Well-known port: Ports from 0 to 1024
– Used by common networking services

Linux+ Guide to Linux Certification, 2e 4


Identifying Network Services
(continued)

Table 15-1: Common well-known ports

Linux+ Guide to Linux Certification, 2e 5


Identifying Network Services
(continued)

• Internet Super Daemon (xinetd): Initializes and


configures many networking services
• Standalone daemons: Daemons normally started at
boot-up
– e.g., Apache Web server
– Configure themselves without assistance
– ntsysv utility can configure most standalone
daemons to start in various runlevels

Linux+ Guide to Linux Certification, 2e 6


Identifying Network Services
(continued)

Figure 15-1: Interacting with network services

Linux+ Guide to Linux Certification, 2e 7


Configuring Common Network
Services

Table 15-2: Common network services


Linux+ Guide to Linux Certification, 2e 8
Configuring Common Network
Services (continued)

Table 15-2 (continued): Common network services


Linux+ Guide to Linux Certification, 2e 9
Configuring Common Network
Services (continued)

Table 15-2 (continued): Common network services


Linux+ Guide to Linux Certification, 2e 10
Configuring Common Network
Services (continued)

Table 15-2 (continued): Common network services


Linux+ Guide to Linux Certification, 2e 11
Configuring Common Network
Services (continued)

Table 15-2 (continued): Common network services

Linux+ Guide to Linux Certification, 2e 12


Configuring DNS

• Zone: Portion of DNS administered by one or more


DNS servers
• Forward lookup: FQDN resolved to IP address
• Reverse lookup: IP address resolved to FQDN

Linux+ Guide to Linux Certification, 2e 13


Configuring DNS (continued)

Figure 15-2: The DNS lookup process


Linux+ Guide to Linux Certification, 2e 14
Configuring DNS (continued)

• Iterative query: Resolved without use of top-level


DNS servers
• Recursive query: Resolved with the use of top-level
DNS servers
• DNS cache file: Contains IP addresses of top-level
DNS servers

Linux+ Guide to Linux Certification, 2e 15


Configuring DNS (continued)

• Master or primary DNS server: Contains read/write


copy of zone
• Slave or secondary DNS server: Contains read-
only copy of zone
• Zone transfer: Copying zone resource records from
master to slave DNS server

Linux+ Guide to Linux Certification, 2e 16


Configuring DNS (continued)

Table 15-3: Common zone configuration files

Linux+ Guide to Linux Certification, 2e 17


Configuring DNS (continued)

Table 15-3 (continued): Common zone configuration files

Linux+ Guide to Linux Certification, 2e 18


Configuring DHCP

• Send DHCP broadcast on network


– Request IP configuration information
• DHCP server leases IP address to client computer
for a period of time
– Ensures each client has unique IP address
• /etc/dhcpd.conf file: Configure computer as a
DHCP server
– List appropriate IP address range for network

Linux+ Guide to Linux Certification, 2e 19


Configuring Apache

• Most common Web server


• Document root directory: Stores default HTML
content for a Web server
– /var/www/html on Fedora Linux
– Default document is index.html
• /etc/httpd/conf/httpd.conf: Default configuration file
• Directive: Line within a configuration file

Linux+ Guide to Linux Certification, 2e 20


Configuring Apache (continued)

Table 15-4: Common httpd.conf directives


Linux+ Guide to Linux Certification, 2e 21
Configuring Samba

• SaMBa daemon: Emulates SMB protocol


• Windows computers advertise computer names
using NetBIOS protocol
– Can use NetBIOS name daemon to create and
advertise NetBIOS name
• Connect Windows computers to Linux server
• smbpasswd command: Generate Samba
passwords

Linux+ Guide to Linux Certification, 2e 22


Configuring Samba (continued)

• /etc/samba/smb.conf: Default Samba configuration


file
• /etc/rc.d/init.d/smb start: Start Samba and NetBIOS
name daemons
– Restart if smb.conf changed

Linux+ Guide to Linux Certification, 2e 23


Configuring NFS

• Create directory containing information to share


• Edit /etc/exports file:
– Add line listing directory to be shared and options
• Run exportfs –a
– Update list of exported filesystems
• Restart the NFS processes

Linux+ Guide to Linux Certification, 2e 24


Configuring FTP

• Very secure FTP daemon (vsftpd): Packaged with


Fedora Linux
• To configure (assuming logon as “user1”):
– Create directory below user1’s home directory to
host the files
• Ensure user1 owns directory
– Run /etc/rc.d/init.d/vsftpd start
• Start vsftpd daemon

Linux+ Guide to Linux Certification, 2e 25


Configuring NIS

• Network Information Service (NIS): Coordinate


common configuration files across several
computers
– Computers belong to a NIS domain, use NIS map to
access configuration information
– Most commonly used for password databases

Linux+ Guide to Linux Certification, 2e 26


Configuring NIS (continued)

• Define the NIS domain via domainname


<NIS_ domain_name> command
• Add “ NISDOMAIN=‘NIS_domain’ ” to
/etc/sysconfig/network file
– Configure NIS domain at boot time
• Add “domain <NIS_domain> server <NIS_server>”
to /etc/yp.conf file
– Query specific NIS server

Linux+ Guide to Linux Certification, 2e 27


Configuring the Secure Shell Daemon

• Secure Shell daemon (sshd): Allows use of ssh


utility to log in to network servers
• /etc/ssh/sshd_config file: Contains configuration
options
• Uses challenge-response authentication by default

Linux+ Guide to Linux Certification, 2e 28


Configuring the Secure Shell Daemon
(continued)

• Supported encryption standards:


– Triple Data Encryption Standard (3DES)
– Advanced Encryption Standard (AES)
– Blowfish
– Carlisle Adams Stafford Tavares (CAST)
– ARCfour

Linux+ Guide to Linux Certification, 2e 29


Routing and Firewall Services

• Network services not provided entirely by network


daemons
– Provided by Linux kernel
– Do not listen to a particular port

Linux+ Guide to Linux Certification, 2e 30


Routing

• Route table: Indicates which networks are


connected to network interfaces
• Route command: Manipulate the route table
• Multihomed hosts: Computers with multiple network
interfaces
• IP forwarding: Forwarding TCP/IP packets between
networks
• Routing: Forwarding data packets between
networks

Linux+ Guide to Linux Certification, 2e 31


Routing (continued)

• Enabling routing:
– Place number 1 in /proc/sys/net/ipv4/ip_forward file
– Place “net.ipv4.ip_forward = 1” in /etc/sysctl.conf file

Linux+ Guide to Linux Certification, 2e 32


Routing (continued)

• Large networks may have several routers


• route add <route> command: Add entries to route
table
• route del <route> command: Remove entries from
route table
• Can use ip command to add entries to route table

Linux+ Guide to Linux Certification, 2e 33


Routing (continued)

Figure 15-3: A sample routed network

Linux+ Guide to Linux Certification, 2e 34


Routing (continued)

• Contents of route table lost when computer


powered off
– Add to /etc/rc.d/rc.local file
• Most routers configured with a default gateway
– For packets addressed to destinations not in route
table
• traceroute command: Troubleshoot routing
– Displays routers between current and remote
computer

Linux+ Guide to Linux Certification, 2e 35


Firewall Services

• netfilter/iptables: Used to create a firewall


– Discard network packets according to chains of rules
• Chains: Specify general type of network traffic to
apply rules to
• Rules: Match network traffic to be allowed or
dropped

Linux+ Guide to Linux Certification, 2e 36


Firewall Services (continued)

• Three chain types:


– INPUT chain: Incoming packets
– FORWARD chain: Packets passing through
computer
– OUTPUT chain: Outgoing packets
• iptables command: Creates rules for a chain

Linux+ Guide to Linux Certification, 2e 37


Firewall Services (continued)

Table 15-5: Common iptables commands


Linux+ Guide to Linux Certification, 2e 38
Security

• Linux systems typically available across networks


such as the Internet
• Should improve local and network security
• Understand how to detect intruders who breach the
system

Linux+ Guide to Linux Certification, 2e 39


Securing the Local Computer

• Limit access to computer itself


– Prevent malicious users from accessing files
• Server closet: Secured room to store servers
• Remove floppy and CD-ROM devices from
workstations
• Ensure BIOS prevents booting from USB ports

Linux+ Guide to Linux Certification, 2e 40


Securing the Local Computer
(continued)

• Ensure BIOS password is set


• Set boot loader password in LILO or GRUB
configuration file
• Limit access to graphical desktops and shells
• Minimize root user’s time logged in

Linux+ Guide to Linux Certification, 2e 41


Securing the Local Computer
(continued)

• nohup command: Prevents other commands from


exiting when parent process killed
• su (switch user) command: Switch current user
account to another
• sudo command: Perform commands as another
user via entries in /etc/sudoers file

Linux+ Guide to Linux Certification, 2e 42


Protecting Against Network Attacks

• Always a possibility that crackers can manipulate a


network service
• Buffer overrun: Network service altered in memory
• Minimize number of running network services
• nmap (network mapper) command: Scan ports on
network computers
– See what network services are running

Linux+ Guide to Linux Certification, 2e 43


Protecting Against Network Attacks
(continued)

• Enable encryption on essential network services


• Ensure network service daemons not run as root
user when possible
• New network service versions usually include fixes
for known network attacks
– Keep network services up-to-date

Linux+ Guide to Linux Certification, 2e 44


Protecting Against Network Attacks
(continued)

• TCP wrapper: Run network daemon with additional


security via /etc/hosts.allow and /etc/hosts.deny
files
• Examine permissions for files and directories
associated with system and network services

Linux+ Guide to Linux Certification, 2e 45


Detecting Intrusion

• Log files can contain information or irregularities


indicating an intrusion
• Review system log files associated with
authentication
• Pluggable Authentication Module (PAM): Handles
authentication requests by daemons
– Log file in /var/log/secure

Linux+ Guide to Linux Certification, 2e 46


Detecting Intrusion (continued)

• Check /var/log/wtmp log file


– Lists users who receive BASH shells
• Tripwire: Monitors files and directories
• Intrusion Detection System (IDS): Detect
unauthorized access

Linux+ Guide to Linux Certification, 2e 47


Detecting Intrusion (continued)

Table 15-6: Common Linux intrusion detection systems


Linux+ Guide to Linux Certification, 2e 48
Summary

• Most network services are started by the Internet


Super Daemon or as standalone daemons and
listen for requests on a port
• Commonly configured network services include
NIS, DNS, DHCP, Samba, Apache, NFS, FTP, and
Secure Shell
• Routing and firewall services are provided by the
Linux kernel

Linux+ Guide to Linux Certification, 2e 49


Summary (continued)

• Securing a Linux computer involves improving local


and network security as well as monitoring to
detect intruders
• By restricting access to your Linux computer and
using the root account only when required, you
greatly improve local Linux security

Linux+ Guide to Linux Certification, 2e 50


Summary (continued)

• Reducing the number of network services, using


firewalls, preventing services from running as the
root user, restricting permissions on key files, and
using TCP wrappers can greatly reduce the chance
of network attacks
• Log files and IDS applications can be used to
detect intruders on a Linux network

Linux+ Guide to Linux Certification, 2e 51

Das könnte Ihnen auch gefallen