Using and Administering Linux: Volume 2, Zero to SysAdmin: Advanced Topics

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

In Using and Administering Linux: Volume 3 you’ll work with multiple VMs on a single physical host to create a network in which to sharpen your sysadmin skills. Chapters have been fully updated to Fedora Linux 38 with expanded content and figures as well brand new material on the BTRFS file system, using Zram for swap, NetworkManager, automation with Ansible, as well as systemd. Focusing on network and other advanced services, this second edition of the final series volume builds upon the skills you have learned so far in volumes 1&2 and will depend upon the virtual network and VMs created there. Start by reviewing the administration of Linux servers and install and configure various Linux server services such as DHCP, DNS, NTP, and SSH server that will be used to provide advanced network services. You’ll then learn to install and configure servers such as BIND for name services, DHCP for network host configuration, and SSH for secure logins to remote hosts. Other topics covered include public/private keypairs to further enhance security, SendMail and IMAP and antispam protection for email, using Apache and WordPress to create and manage web sites, NFS, SAMBA, and Chrony. This volume also covers SELinux and its use in making your systems even more secure., You will learn to build RPMs to be used to distribute automation scripts. All of these services are installed on a single server host over the course of the book and by the time you are finished you will have a single server that provides these services for your network. What You Will Learn Install, configure, and manage several Linux server services such as email with spam management and single and multiple web sites Work with NTP time synchronization, DHCP, SSH, and file sharing with Unix/Linux and Windows clients Create RPMs for distribution of scripts and administrative programs. Understand and work with enhanced security. Who This Book Is For Those who are already Linux power users – SysAdmins who …

Author(s): David Both
Edition: 2
Publisher: Apress
Year: 2023

Language: English
Pages: 536

Table of Contents
About the Author
About the Technical Reviewers
Acknowledgments
Introduction
Chapter 20: Logical Volume Management (LVM)
Objectives
The Need for Logical Volume Management
Running Out of Disk Space in VirtualBox
Recovery
LVM Structure
Extending a Logical Volume
Creating and Extending Volume Groups
Create a New Volume Group
Extend an Existing Volume Group
Tips
Advanced Capabilities
Chapter Summary
Exercises
Chapter 21: File Managers
Objectives
Introduction
Text-Mode Interface
Graphical Interface
Default File Manager
Text-Mode File Managers
Midnight Commander
Other Text-Mode File Managers
Vifm
nnn
Graphical File Managers
Krusader
Thunar
Dolphin
XFE
Other File Managers
Chapter Summary
Exercises
Chapter 22: Everything Is a File
Objectives
What Is a File?
Device Files
Device File Creation
udev Simplification
Naming Rules
Rule Change Blues
Device Data Flow
Device File Classification
Fun with Device Files
Randomness, Zero, and More
Back Up the Master Boot Record
Implications of Everything Is a File
Chapter Summary
Exercises
Chapter 23: Managing Processes
Objectives
Processes
Process Scheduling in the Kernel
Tools
top
Summary Section
Process Section
More About Load Averages …
…and Signals
CPU Hogs
Process Scheduling
Nice Numbers
Killing Processes
Other Interactive Tools
atop
Summary Section
Process Section
Configuration
htop
Summary Section
Process Section
Configuration
Glances
Summary Section
Process Section
Sidebar
Configuration
Other Tools
The Impact of Measurement
Chapter Summary
Exercises
Chapter 24: Special Filesystems
Objectives
Introduction
The /proc Filesystem
The /sys Filesystem
Storage-Based Swap Space
Types of Linux Swap
Thrashing
What Is the Right Amount of Storage-Based Swap Space?
Adding More Swap Space on a Non-LVM Disk Partition
Adding Swap to an LVM Disk Environment
Other Swap Options with LVM
Using Zram for Swap Space
But Why?
How Much Swap?
Managing Zram Swap
Creating Zram Swap
Augmenting Zram Swap
Tuning Swap
Swap Size Recommendations
Removing Traditional Swap Partitions and Files
Chapter Summary
Exercises
Chapter 25: Regular Expressions
Objectives
Introducing Regular Expressions
Getting Started
The Mailing List
The First Solution
The Second Solution
grep
Data Flow
REGEX Building Blocks
Repetition
Other Metacharacters
sed
Other Tools That Implement Regular Expressions
Resources
Chapter Summary
Exercises
Chapter 26: Printing
Objectives
Introduction
About Printers
Print Languages
Printers and Linux
CUPS
Creating the Print Queue
Printing to a PDF File
File Conversion Tools
a2ps
ps2pdf
pr
ps2ascii
Operating System–Related Conversion Tools
unix2dos
dos2unix
unix2mac and mac2unix
Miscellaneous Tools
lpmove
wvText and odt2txt
Chapter Summary
Exercises
Chapter 27: Hardware Detection
Objectives
Introduction
dmidecode
lshw
lsusb
usb-devices
lspci
Cleanup
Chapter Summary
Exercises
Chapter 28: Command-Line Programming
Objectives
Introduction
Definition of a Program
Simple CLI Programs
Some Basic Syntax
Output to the Display
Something About Variables
Control Operators
Return Codes
The Operators
Program Flow Control
true and false
Logical Operators
Syntax
File Operators
String Comparison Operators
Numeric Comparison Operators
Miscellaneous Operators
Grouping Program Statements
Expansions
Brace Expansion
Tilde Expansion
Pathname Expansion
Command Substitution
Arithmetic Expansion
for Loops
Other Loops
while
until
Chapter Summary
Exercises
Chapter 29: Automation with Bash Scripts
Objectives
Introduction
Why I Use Shell Scripts
Shell Scripts
Scripts vs. Compiled Programs
Updates
About Updates
Create a List of Requirements
The CLI Program
Security
Convert the CLI Program to a Script
Add Some Logic
Limit to Root
Add Command-Line Options
Check for Updates
Is a Reboot Required?
Adding a Help Function
Finishing the Script
About Testing
Testing in Production
Fuzzy Testing
Testing the Script
Licensing
Automated Testing
Additional Levels of Automation
Cleanup
Chapter Summary
Exercises
Chapter 30: Automation with Ansible
Objectives
My First Day with Ansible
The Ansible Strategy
My Problem
Getting Started
Installing Ansible
Configuration
ansible.cfg
Preparing to Use Ansible
Ansible Facts
The hosts File
Creating the hosts File
Modules
Introduction to Playbooks
Output
Files
Multiple Playbook Runs
How to Create an Ansible Playbook
What Is a Playbook?
Updates Redux
Defining the Requirements
Syntax
Creating the Playbook
Ansible for Many Systems
The Second Play
The Third Play
Final Thoughts
Resources
Exercises
Chapter 31: Time and Automation
Objectives
Introduction
Keeping Time with Chrony
The NTP Server Hierarchy
NTP Choices
Chrony Structure
Client Configuration
chronyc As an Interactive Tool
Using cron for Timely Automation
The cron Daemon (crond)
crontab
cron Examples
crontab Entries
Creating the crontab File
Other Scheduling Options
/etc/cron.hourly
anacron
Thoughts About cron
Scheduling Tips
Security
cron Resources
at
Syntax
Time Specifications
Security
Setting the Hardware Clock
About Time Zones
Cleanup
Chapter Summary
Exercises
Chapter 32: Networking
Objectives
Introduction
About IPv6
Basic Networking Concepts
Definitions
MAC Address
IP Address
IP Address Assignments
TCP/IP
The TCP/IP Network Model
A Simple Example
CIDR: Network Notation and Configuration
Network Classes
Along Came CIDR
Variable Length Subnet Masking
DHCP Client Configuration
NIC Naming Conventions
How It Works, Sort Of
Interface Configuration Files: Old Style
When Is an Interface Configuration File Needed?
The Interface Configuration File
The networks File
The network File (Deprecated)
The route- File
Name Services
How a Name Search Works
Using the /etc/hosts File
Introduction to Network Routing
The Routing Table
iptraf-ng
Chapter Summary
Exercises
Chapter 33: NetworkManager
Introduction
Network Startup
The NetworkManager Service
What NetworkManager Replaces
What NetworkManager Does
Viewing Interface Configuration
Fixing the Found Problems
Activate and Deactivate Network Connections
NetworkManager Keyfiles
Why Should I Migrate My Files?
Migration Experiments
What If I Don’t Have ifcfg Files?
Reverting to DHCP
Creating New Keyfiles
Text Editor
Using nmtui
Using nmcli
Using the GUI NetworkManager Connection Editor
How to Manage Wireless Networks Using the Command Line
Chapter Summary
Chapter 34: BtrFS
Objectives
Introduction
BtrFS vs. EXT4
BtrFS Advantages
BtrFS and EXT4 Similarities
EXT4 Advantages
Filesystem Structure with BtrFS
How It Works
Creating BtrFS Filesystems
BtrFS RAID Structure
Mounting BtrFS Filesystems
Exploring the BtrFS Volume
Notes on an Edge-Case BtrFS Failure
Simplification
What Is a Subvolume?
Using BtrFS Subvolumes
Converting from EXT to BtrFS
Using BtrFS as Swap
Cleanup
OpenZFS: An Alternative
Chapter Summary
Chapter 35: Getting Started with systemd
Objectives
Introduction
Learning to Love systemd
Linux Boot
Controversy
Why I Prefer SystemV
Why I Prefer systemd
The Real Issue
Previous Work
The systemd Plan to Take Over the World
More Data for the Admin
systemd Standardizes Configuration
Sometimes, the Pain
systemd Tasks
Architecture
Linux Startup with systemd
systemd as PID 1
Exploring Startup
GRUB
Targets
About the Current Target
Using systemd Units
The systemd Suite
Unit Files
systemctl
Service Units
Mounts the Old Way
Creating a Mount Unit
Chapter Summary
Exercises
Chapter 36: Advanced systemd Functions
Objectives
systemd Calendar and Time Spans
Definitions
Absolute Timestamp
Accuracy
Calendar Event
Time Span
Calendar Event Expressions
Exploring systemd Time Syntax
Using systemd Journals
The Journal
The systemd Journal Service
Configuration
About That Binary Data Format…
Using journalctl
Journal Storage Usage
Journal File Rotation
Analyzing systemd Startup and Configuration
Startup Overview
Managing Startup with systemd
Chapter Summary
Exercises
Chapter 37: systemd Finale
Objectives
Introduction
Calendar Event Expression Review
systemd Timers
Creating a Timer
Timer Types
Home Directory Security with systemd-homed
What Is It?
Creating Controlled Users
The homectl Command
Limitations
But I Don’t Want It!
Resource Management with systemd
Using cgroups for Process Management
Exploring the cgroup Hierarchy
Managing cgroups with systemd
Chapter Summary
Exercises
Chapter 38: D-Bus and udev
Objectives
/dev Chaos
About D-Bus
About udev
Naming Rules
Making udev Work
A Basic Script
Refining the Rule into Something Useful
Security
udev in the Real World
Chapter Summary
Exercises
Chapter 39: Using Traditional Logs
Objectives
About Traditional Logs
logrotate
Log File Content
messages
secure
dmesg
Following Log Files
logwatch
Chapter Summary
Exercises
Chapter 40: Managing Users
Objectives
Introduction
The Root Account
Your User Account
Your Home Directory
User Accounts and Groups
The /etc/passwd File
nologin Shells
The /etc/shadow File
The /etc/group File
The /etc/login.defs File
Account Configuration Files
Password Security
Password Encryption
Generating Good Passwords
Password Quality
Managing User Accounts
Creating New Accounts
The useradd Command
Creating New Accounts by Editing the Files
Locking a User Account
Deleting User Accounts
Forcing Account Logoff
Setting Resource Limits
Chapter Summary
Exercises
Chapter 41: Managing the Firewall
Objectives
Introducing Firewalls
Ports
Firewall Rules
Firewall Tools
Block (Almost) Everything
Crunchy on the Outside
firewalld
firewalld Zones
Exploring the Firewall
Adding a New Zone
Zones in a Complex Environment
Adding and Deleting Services
Adding a Service for a Specific Period of Time
Wireless
Using --reload
Zone Files
Minimum Usable Firewall Configuration
Panic Mode
firewall-config GUI
nftables
Outbound Blocking
Fail2ban
Chapter Summary
Exercises
Index