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"

Learn to be a Linux sysadmin and an expert user of the Linux operating system, even with no previous Linux experience. This second edition of the popular and highly rated Linux self-study training course has been fully updated to Fedora Linux 37 with expanded and revised content and figures as well new chapters on the BTRFS file system, using Zram for swap, NetworkManager, automation with Ansible, and systemd. Like the previous version, this edition has been reviewed for technical accuracy by a highly respected Linux expert and will prepare you to manage complex systems with ease and equip you for a new career. It has also been reviewed by a student who took this course to ensure its readability and flow for those with little or no previous experience with Linux. This second volume builds upon what you learned in the first and depends upon the virtual network and virtual machine created there. You’ll see how to manage and monitor running processes, discover the power of the special filesystems, monitor and tune the kernel while it is running – without a reboot. You’ll then turn to regular expressions and the power that using them for pattern matching can bring to the command line, and learn to manage printers and printing from the command line and unlock the secrets of the hardware on which your Linux operating system is running. Experiment with command line programming and how to automate various administrative tasks, networking, and the many services that are required in a Linux system. Use the logs and journals to look for clues to problems and confirmation that things are working correctly, and learn to enhance the security of your Linux systems and how to perform easy local and remote backups. What You Will Learn: • Understand Logical Volume Management, using file managers, and special filesystems • Exploit everything is a file • Perform command line programming and basic automation • Configure printers and manage other hardware • Manage system services with systemd, user management, security, and local and remote backups using simple and freely available tools Who This Book Is For: Anyone who wants to continue to learn Linux in depth as an advanced user and system administrator at the command line while using the GUI desktop to leverage productivity.

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

Language: English
Commentary: TruePDF
Pages: 813
Tags: Open Source; Computer System Implementation

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