The LPIC-2 Exam Prep

Snow B.V.

Heinrich W. Klöpping

Beno T.J. Mesman

Piet W. Plomp

Willem A. Schreuder

Many, many Snow B.V. colleagues for peer reviewing and authoring updates.

Edited by

Jos Jansen

Edited by

Joost Helberg

Abstract

Audience:  this book is intended to help people prepare for the LPIC-2 exam. You will need to have at least 2 years of practical experience with Unix, preferably Linux. Though you may take the LPIC-2 exam without it, you should be an LPIC-1 alumnus to be allowed to the titles and rights that come with the LPIC-2 certification.

Approach:  We wanted to create a set of documents that could help us and others pass the LPIC-2 exams. This book contains all the information (and more) needed to pass the exam.

Sources:  Our sources of information were partly material on the Internet. Mostly practical experience of the authors and others and research done by the authors are to be credited. We try to give credit where due, but are fallible. We apologize.

Caution

While every precaution was made in the preparation of this book, we can assume no responsibility for errors or omissions. When you feel we have not given you proper credit or feel we may have violated your rights or when you have suggestions how we may improve our work please notify us immediately so we can take corrective actions.

Organization of this book:  This book has been organized to follow the Linux Professional Institute level 2 objectives for LPIC-2 certification, first release November 29th 2001, and updated April 1st 2009. The detailed objectives are available via http://www.lpi.org/eng/certification/the_lpic_program/lpic_2. In case the objectives are updated, the book will follow shortly thereafter. The authors use the DocBook documentation standard for this book.


Preface
1. Linux Kernel (201)
Topics
Kernel Components (201.1)
Different types of kernel images
Identifying stable and development kernels and patches
What are kernel modules
Compiling a Kernel (201.2)
Getting the kernel sources
Cleaning the kernel
Creating a .config file
Compiling the kernel
Installing the new kernel
The initial ram disk (initrd)
Patching a Kernel (201.3)
Patching a kernel
Removing a kernel patch from a production kernel
Customise, build and install a custom kernel and kernel modules (201.4)
Using kernel modules
kmod versus kerneld
Manage/Query kernel and kernel modules at runtime (201.5)
2. System Startup (202)
Customizing system startup and boot processes (202.1)
The Linux Boot process
What happens next, what does /sbin/init do?
update-rc.d
The LSB standard
The bootscript environment and commands
System recovery (202.2)
GRUB explained
Influencing the regular boot process
The Rescue Boot process
3. Filesystem and Devices (203)
Operating The Linux Filesystem (203.1)
The File Hierarchy
Filesystems
Creating Filesystems
Mounting and Unmounting
Swap
UUIDs
sync
Maintaining a Linux Filesystem (203.2)
fsck (fsck.e2fs)
tune2fs
dumpe2fs
badblocks
debugfs
Creating And Configuring Filesystem Options (203.3)
Autofs and automounter
CD-ROM filesystem
udev Device Management (203.4)
udev rules
udevmonitor
4. Hardware (2.204)
Configuring RAID (2.204.1)
What is RAID?
RAID levels
Hardware RAID
Software RAID
Recognizing RAID on your Linux system
Configuring RAID (using mdadm)
Adding New Hardware (2.204.2)
Bus structures
USB devices
Serial devices
Configuring disks
Configuring output devices
Software And Kernel Configuration (2.204.3)
Configuring Filesystems
Configuring kernel options
Configuring Logical Volume Management
Configuring IDE CD burners
Configuring harddisks using hdparm
5. Networking (205)
Basic Networking Configuration (205.1)
Configuring the network interface
PPP
Advanced Network Configuration and Troubleshooting (205.2)
Virtual Private Network
Troubleshooting
Troubleshooting network issues (205.3)
Something on network troubleshooting in general
An example situation
Notifying users on system-related issues (205.4)
The /etc/issue, /etc/issue.net, and /etc/motd files
The wall command
The shutdown command communication.
6. System Maintenance (206)
Make and install programs from source (206.1)
Unpacking source code
Building from source
Backup Operations (206.2)
Why?
What?
When?
How?
Where?
Backup utilities
System logging (for your reference)
syslog-ng versus sysklog
Sysklogd
Syslog-ng
Packaging Software (for your reference)
DEB Packages
RPM Packages
7. DNS (2.207)
Basic BIND 9.x configuration (2.207.1)
LPIC 2 objective 207.1
Name-server parts in BIND
The named.conf file
Converting BIND v4 to BIND v8 configuration
The named name server daemon
The rndc program
Sending signals to named
Controlling named with a start/stop script
Create And Maintain DNS Zones (2.207.2)
LPIC 2 objective 207.2
Zones and reverse zones
Master and slave servers
Creating subdomains
DNS Utilities
Securing a DNS Server (2.207.3)
LPIC 2 objective 207.3
DNS Security Strategies
Making information harder to get
Controlling requests
Limiting effects of an intrusion
Securing name server connections
Internal DNS
8. Web Services (2.208)
Implementing a Web Server (2.208.1)
Installing the Apache web-server
Modularity
Run-time loading of modules (DSO)
Encrypted webservers: SSL
Monitoring Apache load and performance
Apache access_log file
Restricting client user access
Configuring authentication modules
User files
Group files
Configuring mod_perl
Configuring mod_php support
Configuring Apache server options
Maintaining a Web Server (2.208.2)
Apache Virtual Hosting
Customizing file access
How to create a SSL server Certificate
Implementing a Proxy Server (2.208.3)
Web-caches
squid
Redirectors
Authenticators
Access policies
Utilizing memory usage
9. File and Service Sharing (2.209)
Configuring a Samba Server (2.209.1)
What is Samba?
Installing the Samba components
An example of the functionality we wish to achieve
Accessing Samba shares from Windows 2000
Accessing Windows or Samba shares from a Linux Samba client
Sending a message with smbclient
Using a Linux Samba printer from Windows 2000
Using a Windows printer from Linux
Setting up an nmbd WINS server
Creating logon scripts for clients
Configuring an NFS Server (2.209.2)
LPIC 2 objective 209.2
NFS - The Network File System
Setting up NFS
Testing NFS
Securing NFS
Overview of NFS components
NFS protocol versions
10. Network Client Management (2.210)
DHCP Configuration (2.210.1)
What is DHCP?
How is the server configured?
An example
Controlling the DHCP-server's behaviour
DHCP-relaying
PAM authentication (2.210.2)
What is it?
How does it work?
Configuring authentication via /etc/passwd and /etc/shadow
Configuring authentication via NIS
Configuring authentication via LDAP
LDAP configuration (2.210.3)
What is it?
Installing and Configuring an LDAP Server
More on LDAP
11. Mail & News (2.206)
Configuring mailing lists (2.206.1)
Installing Majordomo
Creating a Mailing list
Maintaining a Mailinglist
Using Sendmail (2.206.2)
Sendmail configuration
mail aliases
Managing Mail Traffic (2.206.3)
Procmail
Serving news (2.206.4)
Internet News
12. System Security (2.212)
Configuring a router (2.212.2)
Private Network Addresses
Network Address Translation (NAT)
IP Masquerading with IPCHAINS
IP forwarding with IPCHAINS
Port Redirection with IPCHAINS
IPCHAINS, an overview
The Firm's network with IPCHAINS
IPTABLES, an overview
Saving And Restoring Firewall Rules
Denial of Service (DOS) attacks
Routed
PortSentry: Preventing port scans
Securing FTP servers (2.212.3)
FTP server Version 6.4/OpenBSD/Linux-ftpd-0.17
The Washington University FTP Server Version wu-2.6.1
Additional precautions
Secure shell (OpenSSH) (2.212.4)
What are ssh and sshd?
Installing ssh and sshd
Configuring sshd
Keys and their purpose
Configuring the ssh-agent
Tunneling an application protocol over ssh with portmapping
The .rhosts and .shosts files
TCP_wrappers (2.212.5)
What do tcp wrappers do?
What don't tcp wrappers do?
Configuring tcp wrappers
xinetd
Security tasks (2.212.6)
Kerberos
Snort
Tripwire
The nmap command
Keeping track of security alerts
Testing for open mail relays
13. System Customization and Automation (2.213)
Regular Expressions
Introducing Regular Expressions
Primitives and Multipliers
Anchors, Grouping and Alternation
Special characters
Regular Expressions in sed
Regular Expressions in awk
Perl Regular Expressions
Using Perl
Writing simple Perl scripts
Perl basics
Perl taint mode
Perl modules
CPAN
Perl on the command line
Writing Bourne shell scripts
Variables
Branching and looping
Functions
Here documents
Advanced topics
Debugging scripts
Some words on coding style
Using sed
Behaviour
Calling sed
The sed expression
The most frequently used sedcommands
Grouping in sed
White space
Advanced sed
Using awk
Generic flow
Variables and arrays
Input files, records and fields
Branching, looping and other control statements
Patterns
Operators
Using regular expressions
Built-in variables
Functions
rsync
The rsync algorithm
Configuring the rsync daemon
Using the rsync client
crontab
format of the crontab file
The at command
Monitoring your system
parsing a log-file
combine log-files
generate alerts by mail and pager
user login alert
14. Troubleshooting (2.214)
Creating recovery disks (2.214.2)
Why we need bootdisks
Create a bootdisk
initrd
Create a recovery disk
Identifying boot stages (2.214.3)
The bootstrap process
Kernel loading
Daemon initialization
Recognizing the four stages during boot
Troubleshooting LILO (2.214.4)
Booting from CD-ROM and networks
Booting from disk or partition
More about partitions tables
Extended partitions
The LILO install locations
LILO backup files
LILO errors
General troubleshooting (2.214.5)
A word of caution
Getting help
Generic issues with hardware problems
Resolving initial boot problems
Resolving kernel boot problems
Resolving IRQ/DMA conflicts
Troubleshooting tools
Troubleshooting system resources (2.214.6)
Core system variables
Login shells
Shell startup environment
Editors
Setting kernel parameters
Shared libraries
Troubleshooting network issues (2.214.7)
Something on network troubleshooting in general
An example situation
Troubleshooting environment configurations (2.214.8)
Troubleshooting /etc/inittab and /sbin/init
Troubleshooting authorisation problems
Troubleshooting /etc/profile
Troubleshooting /etc/rc.local or /etc/rc.boot
Troubleshooting cron processes
Troubleshooting /etc/`shell_name`.conf
Troubleshooting /etc/login.defs
Troubleshooting /etc/syslog.conf
15.
Troubleshooting network issues (2.214.7)
Something on network troubleshooting in general
An example situation
16.
Troubleshooting environment configurations (2.214.8)
Troubleshooting /etc/inittab and /sbin/init
Troubleshooting authorisation problems
Troubleshooting /etc/profile
Troubleshooting /etc/rc.local or /etc/rc.boot
Troubleshooting cron processes
Troubleshooting /etc/`shell_name`.conf
Troubleshooting /etc/login.defs
Troubleshooting /etc/syslog.conf
A. LPIC Level 2 Objectives
Bibliography
Index

List of Figures

4.1. LVM concepts in ASCII art
8.1. Public key exchange
8.2. Relations between Apache and SSL related projects
13.1. rsync protocol simplified
14.1. A (DOS) partition table entry
14.2. Partition table setup

List of Tables

4.1. Commonly used lspci parameters
4.2. Commonly used setserial parameters
4.3. Common flags for hdparm
7.1. Major BIND components
7.2. Controlling named
7.3. /etc/init.d/bind parameters
9.1. Kernel options for NFS
9.2. Overview of exportfs
9.3. Overview of showmount
9.4. Some options for the nfsstat program
9.5. Overview of NFS-related programs and files
9.6. Overview of NFS protocol versions
10.1. The first two octets are 21.31
10.2. Company-wide services
10.3. Subnet-dependent Services
12.1. Valid chains per table
13.1. Overview of character classes
13.2. Multipliers
13.3. Portable multipliers
13.4. Anchors
13.5. Grouping operators
13.6. Alternation operator
13.7. Extra primitives in Perl
13.8. Perl (non-)word boundary anchors
13.9. Variable types in Perl
13.10. Escape characters in Perl
13.11. Common Environment Variables
13.12. Common Environment Pseudo Variables
13.13. awk operators
14.1. Commonly used environment variables
14.2. Commonly used configuration files in HOME
A.1. LPIC Level 2.201 - 2.205 Objectives And Their Relative Weight
A.2. LPIC Level 2.206 - 2.209 Objectives And Their Relative Weight
A.3. LPIC Level 2.210 - 2.214 Objectives And Their Relative Weight
Copyright Snow B.V. The Netherlands