You are previewing Linux Administration: A Beginner’s Guide (Sixth Edition).
O'Reilly logo
Linux Administration: A Beginner’s Guide (Sixth Edition)

Book Description

Essential Linux Management Skills Made Easy

Effectively deploy and maintain Linux and other Free and Open Source Software (FOSS) on your servers or entire network using this practical resource. Linux Administration: A Beginner’s Guide, Sixth Edition provides up-to-date details on the latest Linux distributions, including Fedora, Red Hat Enterprise Linux, CentOS, Debian, and Ubuntu. Learn how to install and customize Linux, work from the GUI or command line, configure Internet and intranet services, interoperate with Windows systems, and create reliable backups. Performance tuning, security, and virtualization are also covered and real-world examples help you put the techniques presented into practice.

Install and configure popular Linux distributions, including the latest versions of Fedora, CentOS, openSUSE, Debian, and Ubuntu

Administer Linux servers from the GUI or from the command line (shell)

Manage users, permissions, folders, and native FOSS applications

Compile, tune, upgrade, and customize the latest Linux kernel 3.x series

Work with proc, SysFS, and cgroup file systems

Understand and manage the Linux TCP/IP networking stack and services for both IPv4 and IPv6

Build robust firewalls, and routers using Netfilter and Linux

Create and maintain print, e-mail, FTP, and web servers

Use LDAP or NIS for identity management

Set up and administer DNS, POP3, IMAP3, and DHCP servers

Use GlusterFS, NFS, and Samba for sharing and distributing file system resources

Explore and implement Linux virtualization technologies using KVM

Table of Contents

  1. Cover 
  2. Half Title
  3. About the Author
  4. Title
  5. Copyright
  6. Dedication
  7. At a Glance
  8. Contents 
  9. Acknowledgments
  10. Introduction
  11. Part I: Introduction, Installation, and Software Management
    1. 1:  Technical Summary of Linux Distributions
      1. Linux: The Operating System
        1. What Is Open Source Software and GNU All About?
        2. What Is the GNU Public License?
        3. Upstream and Downstream
      2. The Advantages of Open Source Software
      3. Understanding the Differences Between Windows and Linux
        1. Single Users vs. Multiple Users vs. Network Users
        2. The Monolithic Kernel and the Micro-Kernel
        3. Separation of the GUI and the Kernel
        4. The Network Neighborhood
        5. The Registry vs. Text Files
        6. Domains and Active Directory
      4. Summary
    2. 2:  Installing Linux in a Server Configuration
      1. Hardware and Environmental Considerations
      2. Server Design
        1. Uptime
      3. Methods of Installation
      4. Installing Fedora
        1. Project Prerequisites
        2. The Installation
        3. Initial System Configuration
      5. Installing Ubuntu Server
      6. Summary
    3. 3:  Managing Software
      1. The Red Hat Package Manager
        1. Managing Software Using RPM
        2. GUI RPM Package Managers
      2. The Debian Package Management System
        1. APT
      3. Software Management in Ubuntu
        1. Querying for Information
        2. Installing Software in Ubuntu
        3. Removing Software in Ubuntu
      4. Compile and Install GNU Software
        1. Getting and Unpacking the Package
        2. Looking for Documentation
        3. Configuring the Package
        4. Compiling the Package
        5. Installing the Package
        6. Testing the Software
        7. Cleanup
      5. Common Problems When Building from Source Code
        1. Problems with Libraries
        2. Missing Configure Script
        3. Broken Source Code
      6. Summary
  12. Part II: Single-Host Administration
    1. 4:  Managing Users and Groups
      1. What Exactly Constitutes a User?
        1. Where User Information Is Kept
        2. The /etc/passwd File
        3. The /etc/shadow File
        4. The /etc/group File
      2. User Management Tools
        1. Command-Line User Management
        2. GUI User Managers
      3. Users and Access Permissions
        1. Understanding SetUID and SetGID Programs
      4. Pluggable Authentication Modules
        1. How PAM Works
        2. PAM’s Files and Their Locations
        3. Configuring PAM
        4. The “Other” File
        5. D’oh! I Can’t Log In!
        6. Debugging PAM
      5. A Grand Tour
        1. Creating Users with useradd
        2. Creating Groups with groupadd
        3. Modifying User Attributes with usermod
        4. Modifying Group Attributes with groupmod
        5. Deleting Users and Groups with userdel and groupdel
      6. Summary
    2. 5:  The Command Line
      1. An Introduction to BASH
        1. Job Control
        2. Environment Variables
        3. Pipes
        4. Redirection
      2. Command-Line Shortcuts
        1. Filename Expansion
        2. Environment Variables as Parameters
        3. Multiple Commands
        4. Backticks
      3. Documentation Tools
        1. The man Command
        2. The texinfo System
      4. Files, File Types, File Ownership, and File Permissions
        1. Normal Files
        2. Directories
        3. Hard Links
        4. Symbolic Links
        5. Block Devices
        6. Character Devices
        7. Named Pipes
        8. Listing Files: ls
        9. Change Ownership: chown
        10. Change Group: chgrp
        11. Change Mode: chmod
      5. File Management and Manipulation
        1. Copy Files: cp
        2. Move Files: mv
        3. Link Files: ln
        4. Find a File: find
        5. File Compression: gzip
        6. bzip2
        7. Create a Directory: mkdir
        8. Remove a Directory: rmdir
        9. Show Present Working Directory: pwd
        10. Tape Archive: tar
        11. Concatenate Files: cat
        12. Display a File One Screen at a Time: more
        13. Disk Utilization: du
        14. Show the Directory Location of a File: which
        15. Locate a Command: whereis
        16. Disk Free: df
        17. Synchronize Disks: sync
      6. Moving a User and Its Home Directory
        1. List Processes: ps
        2. Show an Interactive List of Processes: top
        3. Send a Signal to a Process: kill
      7. Miscellaneous Tools
        1. Show System Name: uname
        2. Who Is Logged In: who
        3. A Variation on who: w
        4. Switch User: su
      8. Editors
        1. vi
        2. emacs
        3. joe
        4. pico
      9. Summary
    3. 6:  Booting and Shutting Down
      1. Boot Loaders
        1. GRUB Legacy
        2. GRUB 2
        3. LILO
        4. Bootstrapping
      2. The init Process
      3. rc Scripts
        1. Writing Your Own rc Script
      4. Enabling and Disabling Services
        1. Disabling a Service
      5. Odds and Ends of Booting and Shutting Down
        1. fsck!
        2. Booting into Single-User (“Recovery”) Mode
      6. Summary
    4. 7:  File Systems
      1. The Makeup of File Systems
        1. i-Nodes
        2. Block
        3. Superblocks
        4. ext3
        5. ext4
        6. Btrfs
        7. Which File System Should You Use?
      2. Managing File Systems
        1. Mounting and Unmounting Local Disks
        2. Using fsck
      3. Adding a New Disk
        1. Overview of Partitions
        2. Traditional Disk and Partition Naming Conventions
      4. Volume Management
        1. Creating Partitions and Logical Volumes
      5. Creating File Systems
      6. Summary
    5. 8:  Core System Services
      1. The init Daemon
        1. upstart: Die init. Die Now!
        2. The /etc/inittab File
        3. systemd
      2. xinetd and inetd
        1. The /etc/xinetd.conf File
        2. Examples: A Simple Service Entry and Enabling/Disabling a Service
      3. The Logging Daemon
        1. Invoking rsyslogd
      4. Configuring the Logging Daemon
        1. Log Message Classifications
        2. Format of /etc/rsyslog.conf
      5. The cron Program
        1. The crontab File
        2. Editing the crontab File
      6. Summary
    6. 9:  The Linux Kernel
      1. What Exactly Is a Kernel?
      2. Finding the Kernel Source Code
        1. Getting the Correct Kernel Version
        2. Unpacking the Kernel Source Code
      3. Building the Kernel
        1. Preparing to Configure the Kernel
        2. Kernel Configuration
        3. Compiling the Kernel
        4. Installing the Kernel
        5. Booting the Kernel
        6. The Author Lied—It Didn’t Work!
      4. Patching the Kernel
        1. Downloading and Applying Patches
      5. Summary
    7. 10:  Knobs and Dials: Virtual File Systems
      1. What’s Inside the /proc Directory?
        1. Tweaking Files Inside of /proc
      2. Some Useful /proc Entries
        1. Enumerated /proc Entries
      3. Common proc Settings and Reports
        1. SYN Flood Protection
        2. Issues on High-Volume Servers
        3. Debugging Hardware Conflicts
      4. SysFS
      5. cgroupfs
      6. Summary
  13. Part III: Networking and Security
    1. 11:  TCP/IP for System Administrators
      1. The Layers
        1. Packets
        2. TCP/IP Model and the OSI Model
      2. Headers
        1. Ethernet
        2. IP (IPv4)
        3. TCP
        4. UDP
      3. A Complete TCP Connection
        1. Opening a Connection
        2. Transferring Data
        3. Closing the Connection
      4. How ARP Works
        1. The ARP Header: ARP Works with Other Protocols, Too!
      5. Bringing IP Networks Together
        1. Hosts and Networks
        2. Subnetting
        3. Netmasks
        4. Static Routing
        5. Dynamic Routing with RIP
      6. Digging into tcpdump
        1. A Few General Notes
        2. Graphing Odds and Ends
      7. IPv6
        1. IPv6 Address Format
        2. IPv6 Address Types
        3. IPv6 Backward-Compatibility
      8. Summary
    2. 12:  Network Configuration
      1. Modules and Network Interfaces
        1. Network Device Configuration Utilities (ip and ifconfig)
        2. Simple Usage
        3. IP Aliasing
        4. Setting up NICs at Boot Time
      2. Managing Routes
        1. Simple Usage
        2. Displaying Routes
      3. A Simple Linux Router
        1. Routing with Static Routes
      4. How Linux Chooses an IP Address
      5. Summary
    3. 13:  Linux Firewall (Netfilter)
      1. How Netfilter Works
        1. A NAT Primer
        2. NAT-Friendly Protocols
        3. Chains
      2. Installing Netfilter
        1. Enabling Netfilter in the Kernel
      3. Configuring Netfilter
        1. Saving Your Netfilter Configuration
        2. The iptables Command
      4. Cookbook Solutions
        1. Rusty’s Three-Line NAT
        2. Configuring a Simple Firewall
      5. Summary
    4. 14:  Local Security
      1. Common Sources of Risk
        1. SetUID Programs
        2. Unnecessary Processes
      2. Picking the Right Runlevel
      3. Nonhuman User Accounts
      4. Limited Resources
      5. Mitigating Risk
        1. Using chroot
        2. SELinux
        3. AppArmor
      6. Monitoring Your System
        1. Logging
        2. Using ps and netstat
        3. Using df
        4. Automated Monitoring
        5. Mailing Lists
      7. Summary
    5. 15:  Network Security
      1. TCP/IP and Network Security
        1. The Importance of Port Numbers
      2. Tracking Services
        1. Using the netstat Command
        2. Security Implications of netstat’s Output
      3. Binding to an Interface
      4. Shutting Down Services
        1. Shutting Down xinetd and inetd Services
        2. Shutting Down Non-xinetd Services
        3. Shutting Down Services in a Distribution-Independent Way
      5. Monitoring Your System
        1. Making the Best Use of syslog
        2. Monitoring Bandwidth with MRTG
      6. Handling Attacks
        1. Trust Nothing (and No One)
        2. Change Your Passwords
        3. Pull the Plug
      7. Network Security Tools
        1. nmap
        2. Snort
        3. Nessus
        4. Wireshark/tcpdump
      8. Summary
  14. Part IV: Internet Services
    1. 16:  DNS
      1. The Hosts File
      2. How DNS Works
        1. Domain and Host Naming Conventions
        2. Subdomains
        3. The in-addr.arpa Domain
        4. Types of Servers
      3. Installing a DNS Server
        1. Understanding the BIND Configuration File
        2. The Specifics
      4. Configuring a DNS Server
        1. Defining a Primary Zone in the named.conf File
        2. Defining a Secondary Zone in the named.conf File
        3. Defining a Caching Zone in the named.conf File
      5. DNS Records Types
        1. SOA: Start of Authority
        2. NS: Name Server
        3. A: Address Record
        4. PTR: Pointer Record
        5. MX: Mail Exchanger
        6. CNAME: Canonical Name
        7. RP and TXT: The Documentation Entries
      6. Setting up BIND Database Files
        1. Breaking out the Individual Steps
      7. The DNS Toolbox
        1. host
        2. dig
        3. nslookup
        4. whois
        5. nsupdate
        6. The rndc Tool
      8. Configuring DNS Clients
        1. The Resolver
        2. Configuring the Client
      9. Summary
    2. 17:  FTP
      1. The Mechanics of FTP
        1. Client/Server Interactions
      2. Obtaining and Installing vsftpd
        1. Configuring vsftpd
        2. Starting and Testing the FTP Server
      3. Customizing the FTP Server
        1. Setting up an Anonymous-Only FTP Server
        2. Setting up an FTP Server with Virtual Users
      4. Summary
    3. 18:  Apache Web Server
      1. Understanding HTTP
        1. Headers
        2. Ports
        3. Process Ownership and Security
      2. Installing the Apache HTTP Server
        1. Apache Modules
      3. Starting up and Shutting Down Apache
        1. Starting Apache at Boot Time
      4. Testing Your Installation
      5. Configuring Apache
        1. Creating a Simple Root-Level Page
        2. Apache Configuration Files
        3. Common Configuration Options
      6. Troubleshooting Apache
      7. Summary
    4. 19:  SMTP
      1. Understanding SMTP
        1. Rudimentary SMTP Details
        2. Security Implications
      2. Installing the Postfix Server
        1. Installing Postfix via RPM in Fedora
        2. Installing Postfix via APT in Ubuntu
      3. Configuring the Postfix Server
        1. The main.cf File
        2. Checking Your Configuration
      4. Running the Server
        1. Checking the Mail Queue
        2. Flushing the Mail Queue
        3. The newaliases Command
        4. Making Sure Everything Works
      5. Summary
    5. 20:  POP and IMAP
      1. POP and IMAP Basics
      2. Installing the UW-IMAP and POP3 Server
        1. Running UW-IMAP
      3. Other Issues with Mail Services
        1. SSL Security
        2. Testing IMAP and POP3 Connectivity over SSL
        3. Availability
        4. Log Files
      4. Summary
    6. 21:  The Secure Shell (SSH)
      1. Understanding Public Key Cryptography
        1. Key Characteristics
        2. Cryptography References
      2. Understanding SSH Versions
        1. OpenSSH and OpenBSD
        2. Alternative Vendors for SSH Clients
        3. Installing OpenSSH via RPM in Fedora
        4. Installing OpenSSH via APT in Ubuntu
      3. Server Start-up and Shutdown
      4. SSHD Configuration File
      5. Using OpenSSH
        1. Secure Shell (ssh) Client Program
        2. Secure Copy (scp) Program
        3. Secure FTP (sftp) Program
      6. Files Used by the OpenSSH Client
      7. Summary
  15. Part V: Intranet Services
    1. 22:  Network File System (NFS)
      1. The Mechanics of NFS
        1. Versions of NFS
        2. Security Considerations for NFS
        3. Mount and Access a Partition
      2. Enabling NFS in Fedora
      3. Enabling NFS in Ubuntu
      4. The Components of NFS
        1. Kernel Support for NFS
      5. Configuring an NFS Server
        1. The /etc/exports Configuration File
      6. Configuring NFS Clients
        1. The mount Command
        2. Soft vs. Hard Mounts
        3. Cross-Mounting Disks
        4. The Importance of the intr Option
        5. Performance Tuning
      7. Troubleshooting Client-Side NFS Issues
        1. Stale File Handles
        2. Permission Denied
      8. Sample NFS Client and NFS Server Configuration
      9. Common Uses for NFS
      10. Summary
    2. 23:  Samba
      1. The Mechanics of SMB
        1. Usernames and Passwords
        2. Encrypted Passwords
        3. Samba Daemons
        4. Installing Samba via RPM
        5. Installing Samba via APT
      2. Samba Administration
        1. Starting and Stopping Samba
      3. Using SWAT
        1. Setting up SWAT
      4. The SWAT Menus
        1. Globals
        2. Shares
        3. Printers
        4. Status
        5. View
        6. Password
      5. Creating a Share
        1. Using smbclient
      6. Mounting Remote Samba Shares
      7. Samba Users
        1. Creating Samba Users
        2. Allowing Null Passwords
        3. Changing Passwords with smbpasswd
      8. Using Samba to Authenticate Against a Windows Server
        1. winbindd Daemon
      9. Troubleshooting Samba
      10. Summary
    3. 24:  Distributed File Systems
      1. DFS Overview
      2. DFS Implementations
        1. GlusterFS
      3. Summary
    4. 25:  Network Information Service
      1. Inside NIS
      2. The NIS Servers
        1. Domains
      3. Configuring the Master NIS Server
        1. Establishing the Domain Name
        2. Starting NIS
        3. Editing the Makefile
        4. Using ypinit
      4. Configuring an NIS Client
        1. Editing the /etc/yp.conf File
        2. Enabling and Starting ypbind
      5. Editing the /etc/nsswitch.conf File
      6. NIS at Work
        1. Testing Your NIS Client Configuration
      7. Configuring a Secondary NIS Server
        1. Setting the Domain Name
        2. Setting up the NIS Master to Push to Slaves
        3. Running ypinit
      8. NIS Tools
        1. Using NIS in Configuration Files
      9. Implementing NIS in a Real Network
        1. A Small Network
        2. A Segmented Network
        3. Networks Bigger than Buildings
      10. Summary
    5. 26:  LDAP
      1. LDAP Basics
        1. LDAP Directory
        2. Client/Server Model
        3. Uses of LDAP
        4. LDAP Terminology
      2. OpenLDAP
        1. Server-Side Daemons
        2. OpenLDAP Utilities
      3. Installing OpenLDAP
      4. Configuring OpenLDAP
        1. Configuring slapd
        2. Starting and Stopping slapd
      5. Configuring OpenLDAP Clients
        1. Creating Directory Entries
      6. Searching, Querying, and Modifying the Directory
      7. Using OpenLDAP for User Authentication
        1. Configuring the Server
        2. Configuring the Client
      8. Summary
    6. 27:  Printing
      1. Printing Terminologies
      2. The CUPS System
        1. Running CUPS
        2. Installing CUPS
        3. Configuring CUPS
      3. Adding Printers
        1. Local Printers and Remote Printers
      4. Routine CUPS Administration
        1. Setting the Default Printer
        2. Enabling, Disabling, and Deleting Printers
        3. Accepting and Rejecting Print Jobs
        4. Managing Printing Privileges
        5. Managing Printers via the Web Interface
      5. Using Client-Side Printing Tools
        1. lpr
        2. lpq
        3. lprm
      6. Summary
    7. 28:  DHCP
      1. The Mechanics of DHCP
      2. The DHCP Server
        1. Installing DHCP Software via RPM
        2. Installing DHCP Software via APT in Ubuntu
        3. Configuring the DHCP Server
        4. A Sample dhcpd.conf File
      3. The DHCP Client Daemon
        1. Configuring the DHCP Client
      4. Summary
    8. 29:  Virtualization
      1. Why Virtualize?
        1. Virtualization Concepts
      2. Virtualization Implementations
        1. Hyper-V
        2. KVM
        3. QEMU
        4. UML
        5. VirtualBox
        6. VMware
        7. Xen
      3. Kernel-Based Virtual Machines
        1. KVM Example
        2. Managing KVM Virtual Machines
      4. Setting up KVM in Ubuntu/Debian
      5. Summary
    9. 30:  Backups
      1. Evaluating Your Backup Needs
        1. Amount of Data
        2. Backup Hardware and Backup Medium
        3. Network Throughput
        4. Speed and Ease of Data Recovery
        5. Data Deduplication
        6. Tape Management
      2. Command-Line Backup Tools
        1. dump and restore
      3. Miscellaneous Backup Solutions
      4. Summary
  16. Part VI: Appendixes
    1. A:  Creating a Linux Installer on Flash/USB Devices
      1. Creating a Linux Installer on Flash/USB Devices (via Linux OS)
      2. Creating a Linux Installer on Flash/USB Devices (via Microsoft Windows OS)
        1. Fedora Installer Using Live USB Creator on Windows OS
        2. Ubuntu Installer Using UNetbootin on Windows OS
    2. B:  openSUSE Installation
  17. Index