You are previewing Linux Administration: A Beginner’s Guide, Seventh Edition, 7th Edition.
O'Reilly logo
Linux Administration: A Beginner’s Guide, Seventh Edition, 7th Edition

Book Description

Now with a downloadable virtual machine showcasing the book’s test system configuration and updated for the latest Linux kernel release, the new edition of this bestseller teaches system administrators how to set up and configure Linux quickly and easily.

The seventh edition of Linux Administration: A Beginner's Guide takes a proven, step-by-step approach to teaching the fundamentals of Linux system administration, including set-up, configuration, maintenance, networking, and security. Written for all beginner-level system and network admins, this beginner's guide makes it easy for you to translate your basic admin knowledge to Linux system administration and tackle real-world Linux system administration issues.

Part I begins with instructions for Linux server and software installation. Part II details all that is necessary to manage a stand-alone system and Part III introduces Linux security and networking. The remainder of the book is divided into two parts, Part IV: Internet Services and Part V: Intranet Services. The book’s step-by-step design prompts you to follow along and configure your own system. This new edition features a virtual machine showcasing the example system configuration, allowing you to test and compare your own configuration.

  • Covers the major distributions of Linux server for Ubuntu, Fedora, Centos, and openSUSE, and the latest Linux kernel release -- Linux 3.20
  • Now with a virtual machine! Available for download, the virtual machine showcases the final system configuration you will achieve by working through the book
  • Complete with instructor resource materials, featuring PowerPoint slides for classroom use and a test bank of questions that can be used for homework assignments, quizzes, or a final exam

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. At a Glance
  7. Contents
  8. Acknowledgments
  9. Introduction
  10. PART I Introduction, Installation, and Software Management
    1. 1 Technical Summary of Linux Distributions
      1. Linux: The Operating System
      2. What Is Open Source Software and GNU All About?
        1. What Is the GNU Public License?
        2. Upstream and Downstream
      3. The Advantages of Open Source Software
      4. 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. My Network Places
        5. The Registry vs. Text Files
        6. Domains and Active Directory
      5. 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
      5. The Installation
      6. Installation Summary
        1. Localization Section
        2. Software Section
        3. System Section
        4. Start the Installation, Set the Root Password, and Create a User Account
        5. Complete the Installation
        6. Log In
      7. Installing Ubuntu Server
        1. Start the Installation
        2. Configure the Network
        3. Set Up Users and Passwords
        4. Configure the Time Zone
        5. Set Up the Disk Partition
        6. Other Miscellaneous Tasks
      8. Summary
    3. 3 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. File Compression: bzip2
        7. File Compression: xz
        8. Create a Directory: mkdir
        9. Remove a Directory: rmdir
        10. Show Present Working Directory: pwd
        11. Tape Archive: tar
        12. Concatenate Files: cat
        13. Display a File One Screen at a Time: more
        14. Show the Directory Location of a File: which
        15. Locate a Command: whereis
      6. Editors
        1. vi
        2. emacs
        3. joe
        4. pico
      7. Miscellaneous Tools
        1. Disk Utilization: du
        2. Disk Free: df
        3. Synchronize Disks: sync
        4. List Processes: ps
        5. Show an Interactive List of Processes: top
        6. Send a Signal to a Process: kill
        7. Show System Name: uname
        8. Who Is Logged In: who
        9. A Variation on who: w
        10. Switch User: su
      8. Putting It All Together (Moving a User and Its Home Directory)
      9. Summary
    4. 4 Managing Software
      1. The Red Hat Package Manager
      2. Managing Software Using RPM
        1. Querying for Information the RPM Way (Getting to Know One Another)
        2. Installing Software with RPM (Moving in Together)
        3. Uninstalling Software with RPM (Ending the Relationship)
        4. Other Things RPM Can Do
      3. Yum
      4. DNF
      5. GUI RPM Package Managers
        1. Fedora
        2. openSUSE and SLE
      6. The Debian Package Management System
        1. APT
      7. Software Management in Ubuntu
        1. Querying for Information
        2. Installing Software in Ubuntu
        3. Removing Software in Ubuntu
      8. Compile and Install GNU Software
        1. Getting and Unpacking the Source Package
        2. Looking for Documentation
        3. Configuring the Package
        4. Compiling the Package
        5. Installing the Package
        6. Testing the Software
        7. Cleanup
      9. Common Problems When Building from Source Code
        1. Problems with Libraries
        2. Missing Configure Script
        3. Broken Source Code
      10. Summary
  11. PART II Single-Host Administration
    1. 5 Managing Users and Groups
      1. What Exactly Constitutes a User?
      2. Where User Information Is Kept
        1. The /etc/passwd File
        2. The /etc/shadow File
        3. The /etc/group File
      3. User Management Tools
        1. Command-Line User Management
        2. GUI User Managers
      4. Users and Access Permissions
        1. Understanding SetUID and SetGID Programs
        2. Sticky Bit
      5. Pluggable Authentication Modules
        1. How PAM Works
        2. PAM’s Files and Their Locations
        3. Configuring PAM
        4. An Example PAM Configuration File
        5. The “Other” File
        6. D’oh! I Can’t Log In!
        7. Debugging PAM
      6. 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
      7. Summary
    2. 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. Enabling a Service
        2. Disabling a Service
      5. Graphical Service Managers
      6. Odds and Ends of Booting and Shutting Down
        1. fsck!
        2. Booting into Single-User (“Recovery”) Mode
      7. Summary
    3. 7 File Systems
      1. The Makeup of File Systems
        1. i-Nodes
        2. Blocks
        3. Superblocks
        4. ext3
        5. ext4
        6. Btrfs
        7. XFS
        8. 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
    4. 8 Core System Services
      1. The init Daemon
        1. upstart: Die init. Die Now!
      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. rsyslogd
        2. systemd-journald (journald)
      4. The cron Program
        1. The crontab File
        2. Editing the crontab File
      5. Summary
    5. 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
        2. If the Patch Worked
        3. If the Patch Didn’t Work
      5. Summary
    6. 10 Knobs and Dials: API (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. tmpfs
        1. tmpfs Example
      7. Summary
  12. 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. tcpdump Bits and Bobs
        1. Reading and Writing Dumpfiles
        2. Capturing More or Less per Packet
        3. Performance Impact
        4. Don’t Capture Your Own Network Traffic
        5. Troubleshooting Slow Name Resolution (DNS) Issues
      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, ifconfig, and nmcli)
        2. Sample Usage—ifconfig, ip, and nmcli
        3. Setting Up NICs at Boot Time
      2. Managing Routes
        1. Sample Usage: Route Configuration
        2. Displaying Routes
      3. A Simple Linux Router
        1. Routing with Static Routes
      4. How Linux Chooses an IP Address
      5. Hostname Configuration
      6. 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
        3. firewalld
      4. Cookbook Solutions
        1. Simple NAT: iptables
        2. Simple NAT: nftables
        3. Simple Firewall: iptables
      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. 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
      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
  13. PART IV Internet Services
    1. 16 Domain Name System (DNS)
      1. The Hosts File
      2. How DNS Works
        1. Domain and Host Naming Conventions
        2. The Root Domain
        3. Subdomains
        4. The in-addr.arpa Domain
        5. 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. DNS Server Setup Walk-Through
      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 File Transfer Protocol (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 Simple Mail Transfer Protocol (SMTP)
      1. Understanding SMTP
        1. Rudimentary SMTP Details
        2. Security Implications
        3. Email Components
      2. Installing the Postfix Server
        1. Installing Postfix via RPM in Fedora
        2. Installing Postfix via APT in Ubuntu
        3. Installing Postfix from Source Code
      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 Post Office Protocol and Internet Mail Access Protocol (POP and IMAP)
      1. POP3 and IMAP Protocol Basics
      2. Dovecot (IMAP and POP3 Server)
      3. Installing Dovecot
        1. Dovecot Configuration Files and Options
        2. Configuring Dovecot
        3. Running Dovecot
        4. Checking Basic POP3 Functionality
        5. Checking Basic IMAP Functionality
      4. Other Issues with Mail Services
        1. SSL Security
        2. Availability
        3. Log Files
      5. Summary
    6. 21 Voice over Internet Protocol (VoIP)
      1. VoIP Overview
        1. VoIP Server
        2. Analog Telephone Adapter (ATA)
        3. IP Phones
        4. VoIP Protocols
      2. VoIP Implementations
      3. Asterisk
        1. How Asterisk Works
      4. Asterisk Installation
        1. Starting and Stopping Asterisk
      5. Understanding Asterisk Configuration Files and Structure
        1. SIP Channel Config: sip.conf
        2. The Dialplan: extensions.conf
        3. Modules: modules.conf
      6. Asterisk Network, Port, and Firewall Requirements
        1. Configuring the Local Firewall for Asterisk
      7. Configuring the PBX
        1. Local Extensions
        2. Outside Connection—(VoIP Trunking)
        3. Trunking Using Google Voice
      8. Asterisk Maintenance and Troubleshooting
        1. Asterisk CLI Commands
        2. Helpful CLI Commands
        3. Common Issues with VoIP
      9. Summary
      10. 22 Secure Shell (SSH)
      11. Understanding Public Key Cryptography
        1. Key Characteristics
        2. Cryptography References
      12. 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
      13. Server Start-up and Shutdown
      14. SSHD Configuration File
      15. Using OpenSSH
        1. Secure Shell (ssh) Client Program
        2. Secure Copy (scp) Program
        3. Secure FTP (sftp) Program
      16. Files Used by the OpenSSH Client
      17. Summary
  14. PART V Intranet Services
    1. 23 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, RHEL, and Centos
      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. 24 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. Creating a Share
        1. Using smbclient
      4. Mounting Remote Samba Shares
      5. Samba Users
        1. Creating Samba Users
        2. Allowing Null Passwords
        3. Changing Passwords with smbpasswd
      6. Using Samba to Authenticate Against a Windows Server
        1. winbindd Daemon
      7. Troubleshooting Samba
      8. Summary
    3. 25 Distributed File Systems (DFS)
      1. DFS Overview
      2. DFS Implementations
        1. GlusterFS
      3. Summary
    4. 26 Network Information Service (NIS)
      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. Install NIS Client-Side Package
        2. Editing the /etc/yp.conf File
        3. 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. 27 Lightweight Directory Access Protocol (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
        5. Configuring slapd
        6. Starting and Stopping slapd
      3. Configuring OpenLDAP Clients
        1. Creating Directory Entries
      4. Searching, Querying, and Modifying the Directory
      5. Using OpenLDAP for User Authentication
        1. Configuring the Server
        2. Configuring the Client
      6. Summary
    6. 28 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
        2. Using the Web Interface to Add a Printer
        3. Using Command-Line Tools to Add a Printer
      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. 29 Dynamic Host Configuration Protocol (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. 30 Virtualization
      1. Why Virtualize?
        1. Virtualization Concepts
      2. Virtualization Implementations
        1. Hyper-V
        2. Kernel-Based Virtual Machine (KVM)
        3. QEMU
        4. User-Mode Linux (UML)
        5. VirtualBox
        6. VMware
        7. Xen
      3. KVM
        1. KVM Example
        2. Managing KVM Virtual Machines
      4. Setting Up KVM in Ubuntu/Debian
      5. Containers
        1. Containers vs. Virtual Machines
        2. Docker
      6. Summary
    9. 31 Backups
      1. Evaluating Your Backup Needs
      2. Amount of Data
      3. Backup Hardware and Backup Medium
      4. Network Throughput
      5. Speed and Ease of Data Recovery
      6. Data Deduplication
      7. Tape Management
      8. Command-Line Backup Tools
      9. dump and restore
      10. tar
      11. rsync
      12. Miscellaneous Backup Solutions
      13. Summary
  15. 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)
        1. Fedora Installer Using Live USB Creator on Windows
        2. Ubuntu Installer Using UNetbootin on Windows
        3. OpenSUSE Installer Using Pendrivelinux.com’s Universal USB Installer on Windows
    2. B Demo Virtual Machine
      1. Basic Host System Requirements
      2. Installing the Virtualization Applications and Utilities
      3. Download and Prep the Demo VM Image File
      4. Import the Demo VM Image and Create a New VM Instance
        1. Managing the Demo Virtual Machine
      5. Connecting to the Demo VM
        1. Virtual Network Computing (VNC)
        2. Connecting via SSH
        3. Virtual Serial TTY Console
        4. Cockpit Application
        5. Just Use It!
      6. Feedback
  16. Index