
Mastering Linux System Administration
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
In Mastering Linux System Administration, Linux experts and system administrators Christine Bresnahan and Richard Blum deliver a comprehensive roadmap to go from Linux beginner to expert Linux system administrator with a learning-by-doing approach. Organized by do-it-yourself tasks, the book includes instructor materials like a sample syllabus, additional review questions, and slide decks.
Amongst the practical applications of the Linux operating system included within, you'll find detailed and easy-to-follow instruction on:
* Installing Linux servers, understanding the boot and initialization processes, managing hardware, and working with networks
* Accessing the Linux command line, working with the virtual directory structure, and creating shell scripts to automate administrative tasks
* Managing Linux user accounts, system security, web and database servers, and virtualization environments
Perfect for entry-level Linux system administrators, as well as system administrators familiar with Windows, Mac, NetWare, or other UNIX systems, Mastering Linux System Administration is a must-read guide to manage and secure Linux servers.
More details
Other editions
Additional editions

Persons
Richard Blum has over thirty years of experience working as a system and network administrator. He teaches online courses in Linux and Web programming and is co-author with Christine Bresnahan of several Linux titles, including CompTIA Linux+ Study Guide, Linux Essentials, and the Linux Command Line and Scripting Bible.
Content
- Cover
- Title Page
- Copyright Page
- Acknowledgments
- About the Authors
- About the Technical Editor
- Contents at a Glance
- Contents
- Introduction
- Who Should Read This Book
- What You Will Learn
- What You Need
- The Mastering Series
- How to Contact Wiley or the Authors
- Part 1 Basic Admin Functions
- Chapter 1 Understanding the Basics
- What Is Linux?
- Looking into the Linux Kernel
- The GNU Utilities
- Linux User Interfaces
- Linux Distributions
- Core Linux Distributions
- Specialized Linux Distributions
- The Bottom Line
- Chapter 2 Installing an Ubuntu Server
- Pre-Installation Requirements
- Hardware Requirements
- Virtual Server Requirements
- Finding the Software
- Oracle VirtualBox
- Ubuntu Server
- Running the Installation
- Oracle VirtualBox
- Ubuntu Server
- Checking the Installation
- The Bottom Line
- Chapter 3 Installing and Maintaining Software in Ubuntu
- Exploring Package Management
- Inspecting the Debian-Based Systems
- Managing Packages with apt
- Installing Software Packages with apt
- Upgrading Software with apt
- Uninstalling Software with apt
- The apt Repositories
- Using Snap Containers
- Installing from Source Code
- The Bottom Line
- Chapter 4 Installing a Red Hat Server
- Pre-Installation Requirements
- Hardware Requirements
- Virtual Server Requirements
- Finding the Software
- Oracle VirtualBox
- CentOS
- Running the Installation
- Oracle VirtualBox
- CentOS
- Checking the Installation
- The Bottom Line
- Chapter 5 Installing and Maintaining Software in Red Hat
- Exploring Red Hat Packages
- Automated Package Management
- Listing Installed Packages
- Installing Software with dnf
- Upgrading Software with dnf
- Uninstalling Software with dnf
- Handling Broken Dependencies
- Working with RPM Repositories
- Working Directly with Packages
- Finding Package Files
- Inspecting Package Files
- Installing Package Files
- Removing Package Files
- Using Flatpak Containers
- The Bottom Line
- Chapter 6 Working with the Shell
- Exploring the Shell
- The Shell Prompt
- The Shell Manual
- Working with Commands
- Entering Commands
- Retrieving Past Commands
- Redirecting Commands
- Environment Variables
- Global Environment Variables
- User-Defined Environment Variables
- The Bottom Line
- Chapter 7 Exploring Linux File Management
- Filesystem Navigation
- The Linux Filesystem
- Traversing Directories
- Linux Files
- Determining File Types
- Filenames
- Hidden Files
- File Inodes
- File and Directory Listing
- Basic Listing
- Modifying Listing Information
- The Complete Parameter List
- Directory Handling
- Creating Directories
- Deleting Directories
- File Handling
- Creating Files
- Copying Files
- Linking Files
- Renaming Files
- Deleting Files
- File Features
- Using Wildcards
- Quoting
- Case Sensitivity
- Finding Files
- The which Command
- The locate Command
- The whereis Command
- The find Command
- Archiving Files
- Compressing Files
- Creating Archive Files
- Archiving Scenarios
- The Bottom Line
- Chapter 8 Working with Text Files
- The vim Editor
- Checking Your vim Editor Program
- Using the vim Editor
- The nano Editor
- Working with Data Files
- Sorting
- Searching
- Compressing
- Archiving
- The Bottom Line
- Part 2 Intermediate Admin Functions
- Chapter 9 Managing Hardware
- Device Driver Modules
- Listing Installed Modules
- Installing New Modules
- Removing Modules
- Communicating with Devices
- Device Interfaces
- The /dev Directory
- The /proc Directory
- The /sys Directory
- Working with Devices
- Finding Devices
- Working with PCI Cards
- Working with USB Devices
- Using Hot Pluggable Devices
- Detecting Dynamic Devices
- Working with Dynamic Devices
- The Bottom Line
- Chapter 10 Booting Linux
- Understanding the Boot Process
- Overview of the Boot Process
- Watching the Boot Process
- The Firmware Startup
- The GRUB2 Bootloader
- Configuring the GRUB2 Bootloader
- Exploring the GRUB2 Configuration
- Interacting with GRUB2
- The systemd Initialization Process
- Exploring Unit Files
- Focusing on Service Unit Files
- Focusing on Target Unit Files
- Changing a Unit Configuration File
- Changing the systemd Configuration File
- Looking at systemctl
- Jumping Targets
- Analyzing with systemd
- The Bottom Line
- Chapter 11 Working with Storage Devices
- Storage Basics
- Drive Connections
- Partitioning Drives
- Automatic Drive Detection
- Partitioning Tools
- Working with fdisk
- Working with gdisk
- The GNU parted Command
- Formatting Filesystems
- Common Filesystem Types
- Creating Filesystems
- Mounting Filesystems
- Manually Mounting Devices
- Automatically Mounting Devices
- Managing Filesystems
- Retrieving Filesystem Stats
- Filesystem Tools
- Storage Alternatives
- Multipath
- Logical Volume Manager
- Using RAID Technology
- The Bottom Line
- Chapter 12 Configuring Network Settings
- Network Settings
- Ubuntu Servers
- Red Hat Servers
- Using Network Command-Line Tools
- NetworkManager Tools
- Other Tools
- Basic Network Troubleshooting
- Sending Test Packets
- Finding Host Information
- Advanced Network Troubleshooting
- The netstat Command
- Examining Sockets
- The Bottom Line
- Chapter 13 Managing Users and Groups
- Understanding Linux Permissions
- Understanding Ownership
- Controlling Access Permissions
- Exploring Special Permissions
- Managing Default Permissions
- Using Access Control Lists
- Managing User Accounts
- Adding Accounts
- Maintaining Accounts
- Removing Accounts
- Maintaining the Environment
- Setting Environment Variables
- Exploring User Entries
- Exploring Global Entries
- Managing Groups
- Adding Groups
- Removing Groups
- The Bottom Line
- Chapter 14 Working with Processes and Jobs
- Looking at Processes
- Monitoring Processes in Real Time
- Managing Processes
- Setting Priorities
- Stopping Processes
- Running Programs in Background Mode
- Running in the Background
- Running Multiple Background Jobs
- Running Programs Without a Console
- Job Control
- Viewing Jobs
- Restarting Stopped Jobs
- Scheduling Jobs
- Scheduling a Job Using the at Command
- Scheduling Recurring Programs
- The Bottom Line
- Chapter 15 Managing Log Files
- The systemd Journaling System
- Configuring systemd-journald
- Looking at Journal Files
- Making the Journal Persistent
- Viewing Journal Entries
- Maintaining the Journal
- Viewing Different Journal Files
- Protecting Journal Files
- Making Journal Entries
- The rsyslog Legacy System
- The syslog Protocol
- Basic Logging Using rsyslogd
- Layering Your Logging
- Making Log Entries
- Finding Event Messages
- The Bottom Line
- Chapter 16 Managing Printers
- The Common Unix Printing System
- Printer Drivers
- Web Interface
- Command-Line Commands
- Printer Sharing
- Printer Classes
- Installing and Configuring CUPS
- Installing CUPS
- Preparing the Server to Use CUPS
- Using CUPS
- Administration Functions
- Managing Printers and Jobs in CUPS
- The Bottom Line
- Part 3 Advanced Admin Functions
- Chapter 17 Exploring Ubuntu Security
- Locking Down Root
- Looking at Linux Account Types
- Gaining Super User Privileges
- Using OpenSSH on Ubuntu
- Exploring Basic SSH Concepts
- Configuring SSH
- Generating SSH Keys
- Authenticating with SSH Keys
- The AppArmor System
- Network Security Using Firewalls
- Understanding UFW
- Configuring UFW
- The Bottom Line
- Chapter 18 Exploring Red Hat Security
- Working with Root Access
- Keeping Track of Root Logins
- Disabling Root Access from SSH
- Enabling Automatic Logout
- Blocking Root Access
- Using SELinux
- Enabling SELinux
- Understanding Security Context
- Using Policies
- Network Security Using Firewalls
- Red Hat Firewall Concepts
- Checking the Firewall Status
- Working with Zones
- Working with Firewall Rules
- The Bottom Line
- Chapter 19 Writing Scripts
- Beginning a Shell Script
- Creating a Script File
- Displaying Messages
- Using Variables
- Environment Variables
- User Variables
- Command Substitution
- Exiting the Script with Status
- Passing Parameters
- Adding Conditional Expressions
- Working with the if-then Statement
- Using Compound Tests
- Working with the if-then-else Statement
- Trying the case Statement
- Using Loops
- Looking at the for Command
- Working with the while Format
- Using the until Command
- Using Functions
- Creating Functions
- Calling Functions
- The Bottom Line
- Chapter 20 Managing Web Servers
- Linux Web Servers
- Apache
- nginx
- The Apache Web Server
- Installing an Apache Server
- Configuring the Apache Server
- Hosting Dynamic Web Applications
- Creating a Secure Web Server
- The nginx Server
- Installing nginx
- Configuring nginx
- The Bottom Line
- Chapter 21 Managing Database Servers
- Linux Database Servers
- Organizing the Data
- Querying the Data
- Controlling the Data
- Installing and Using MySQL/MariaDB
- Conducting a MariaDB Installation
- Accessing a MariaDB Database
- Populating and Using MariaDB Database
- Installing and Using PostgreSQL
- Conducting a PostgreSQL Installation
- Accessing a PostgreSQL Database
- Populating and Using a PostgreSQL Database
- The Bottom Line
- Chapter 22 Exploring the Virtualization Environment
- Hypervisors
- Managing VMs
- Creating a Virtual Machine
- Integrating via Linux Extensions
- Containers
- Exploring Container Types
- Looking at Container Software
- Organizing Containers
- Software Packaging
- Looking at Ubuntu Snap
- Looking at Flatpak
- The Bottom Line
- Appendix The Bottom Line
- Chapter 1: Understanding the Basics
- Chapter 2: Installing an Ubuntu Server
- Chapter 3: Installing and Maintaining Software in Ubuntu
- Chapter 4: Installing a Red Hat Server
- Chapter 5: Installing and Maintaining Software in Red Hat
- Chapter 6: Working with the Shell
- Chapter 7: Exploring Linux File Management
- Chapter 8: Working with Text Files
- Chapter 9: Managing Hardware
- Chapter 10: Booting Linux
- Chapter 11: Working with Storage Devices
- Chapter 12: Configuring Network Settings
- Chapter 13: Managing Users and Groups
- Chapter 14: Working with Processes and Jobs
- Chapter 15: Managing Log Files
- Chapter 16: Managing Printers
- Chapter 17: Exploring Ubuntu Security
- Chapter 18: Exploring Red Hat Security
- Chapter 19: Writing Scripts
- Chapter 20: Managing Web Servers
- Chapter 21: Managing Database Servers
- Chapter 22: Exploring the Virtualization Environment
- Index
- EULA
Chapter 1
Understanding the Basics
The Linux operating system has taken the world by storm. Whether it's embedded Linux software operating in phones and refrigerators or full-blown Linux servers running famous Internet sites, you can find Linux systems just about everywhere. If you've chosen (or have been chosen) to be a Linux system administrator, the task before you can seem daunting at first. But don't panic-while complex, the Linux system is organized and structured. Just knowing the basics of how Linux works will go a long way in helping you with your goals of becoming a Linux system administrator. This chapter walks you through the basics of what Linux is and explains the different versions of Linux that are available.
IN THIS CHAPTER, YOU WILL LEARN TO
- List the components of a standard Linux system
- Explain how GNU utilities are used in Linux
- Describe the various Linux user interface environments
- Explain why there are different Linux distributions
What Is Linux?
If you've never worked with Linux, you may be confused as to why there are so many different versions of it available. You've probably heard various terms such as distribution, LiveDVD, and GNU when looking at Linux packages, and may have been confused. Wading through the world of Linux for the first time can be a tricky experience. This chapter takes some of the mystery out of the Linux system before you start working on commands and scripts.
For starters, these four main parts make up a Linux system:
- The Linux kernel
- The GNU utilities
- A user interface
- Application software
Each of these four parts has a specific job in the Linux system. Figure 1.1 shows a basic diagram of how the parts fit together on top of the computer hardware to create the overall Linux system.
FIGURE 1.1 The Linux system
This section describes these four main parts in detail and gives you an overview of how they work together to create a complete Linux system.
Looking into the Linux Kernel
The core of the Linux system is the kernel. The kernel controls all of the hardware and software on the computer system, allocating hardware when necessary and executing software when required.
If you've been following the Linux world at all, no doubt you've heard the name Linus Torvalds. Linus is the person responsible for creating the first Linux kernel software while he was a student at the University of Helsinki. He intended it to be a copy of the Unix system, at the time a popular operating system used at many universities.
After developing the Linux kernel, Linus released it to the Internet community and solicited suggestions for improving it. This simple process started a revolution in the world of computer operating systems. Soon Linus was receiving suggestions from students as well as professional programmers from around the world.
Allowing anyone to change programming code in the kernel would result in complete chaos. To simplify things, Linus acted as a central point for all improvement suggestions. It was ultimately Linus's decision whether to incorporate suggested code in the kernel. This same concept is still in place with the Linux kernel code, except that instead of just Linus controlling the kernel code, a team of developers has taken on the task.
The kernel is primarily responsible for these four main functions:
- System memory management
- Software program management
- Hardware management
- Filesystem management
The following sections explore each of these functions in more detail.
SYSTEM MEMORY MANAGEMENT
One of the primary functions of the operating system kernel is memory management. Not only does the kernel manage the physical memory available on the server, but it can also create and manage virtual memory, or memory that does not actually exist.
It does this by using space on the hard disk, called the swap space. The kernel swaps the contents of virtual memory locations back and forth from the swap space to the actual physical memory. This allows the system to think there is more memory available than what physically exists (shown in Figure 1.2).
FIGURE 1.2 The Linux system memory map
The memory locations are grouped into blocks called pages. The kernel locates each page of memory either in the physical memory or in the swap space. The kernel then maintains a table of the memory pages that indicates which pages are in physical memory and which pages are swapped out to disk.
The kernel keeps track of which memory pages are in use and automatically copies memory pages that have not been accessed for a period of time to the swap space area (called swapping out), even if there's other memory available. When a program wants to access a memory page that has been swapped out, the kernel must make room for it in physical memory by swapping out a different memory page and swapping in the required page from the swap space. Obviously, this process takes time and can slow down a running process. The process of swapping out memory pages for running applications continues for as long as the Linux system is running.
Real World Scenario
LOOKING AT MEMORY
There are a couple of simple commands you can use to get an idea of just how your Linux system is managing memory. While we'll be exploring these commands in more detail later in the book, here's a quick exercise for you to get started exploring your Linux system:
- Log into your Linux system. (If you don't have a Linux system available yet, you can come back to here after going through either Chapter 2, "Installing an Ubuntu Server," or Chapter 4, "Installing a Red Hat Server.")
- From the command prompt, enter the command
free. You should see something similar to this output:$ freetotal used free shared buff/cache availableMem: 2035504 135668 1449568 1048 450268 1742704Swap: 2097148 0 2097148The output from the
freecommand shows the total amount of physical memory installed on the system, as well as the amount of swap space currently configured. - The
freecommand just provides an overview of the memory for your Linux system. For a more detailed look, enter the commandcat /proc/meminfo. You should see a long listing, similar to this:$ cat /proc/meminfoMemTotal: 2035504 kBMemFree: 1449632 kBMemAvailable: 1742352 kBBuffers: 25452 kBCached: 386028 kBSwapCached: 0 kBActive: 166036 kBInactive: 290704 kBActive(anon): 51796 kBInactive(anon): 128 kBActive(file): 114240 kBInactive(file): 290576 kBUnevictable: 18640 kBMlocked: 18640 kBSwapTotal: 2097148 kBSwapFree: 2097148 kBDirty: 156 kBWriteback: 0 kBAnonPages: 63940 kBMapped: 63344 kBShmem: 1048 kBKReclaimable: 38664 kBSlab: 74316 kBSReclaimable: 38664 kBSUnreclaim: 35652 kBKernelStack: 2044 kBPageTables: 1268 kBNFS_Unstable: 0 kBBounce: 0 kBWritebackTmp: 0 kBCommitLimit: 3114900 kBCommitted_AS: 376812 kBVmallocTotal: 34359738367 kBVmallocUsed: 27676 kBVmallocChunk: 0 kBPercpu: 516 kBHardwareCorrupted: 0 kBAnonHugePages: 0 kBShmemHugePages: 0 kBShmemPmdMapped: 0 kBFileHugePages: 0 kBFilePmdMapped: 0 kBCmaTotal: 0 kBCmaFree: 0 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 2048 kBHugetlb: 0 kBDirectMap4k: 90048 kBDirectMap2M: 2007040 kB$The kernel continually updates the
meminfofile to show exactly what's going on in memory at that moment in time, so the file constantly changes.
SOFTWARE PROGRAM MANAGEMENT
The Linux operating system calls a running program a process. A process can run in the foreground, displaying output on a display, or it can run in background, behind the scenes. The kernel controls how the Linux system manages all the processes running on the system.
The kernel creates the first process, called the init process, to start all other processes on the system. When the kernel starts, it loads the init...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.