Linux Cookbook
by Carla Schroder
Copyright 2021 Carla Schroder. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Suzanne McQuade
- Development Editor: Jeff Bleiel
- Production Editor: Daniel Elfanbaum
- Copyeditor: Sonia Saruba
- Proofreader: Tom Sullivan
- Indexer: nSight, Inc.
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Kate Dullea
- December 2004: First Edition
- September 2021: Second Edition
Revision History for the Second Edition
- 2021-08-12: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492087168 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Linux Cookbook, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the author, and do not represent the publishers views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-08716-8
[LSI]
Preface
Way back in olden times I wrote the first edition of the Linux Cookbook, whichwas released unto a joyous world in 2004. It sold well, I heard from manyhappy readers, and some are still my friends.
For a Linux book, 17 years old is ancient. Linux was 14 years old in 2004, awee baby computer operating system. Even so, it was already a popularand widely used powerhouse, adapting to any role, from tiny embedded devicesto mainframes and supercomputers. The rapid growth of Linux is partly due to itbeing a free clone of Unix, the most mature and powerful operating system of all.The other major factor in the speedy growth and adoption of Linux is the absenceof barriers. Anyone can download and try it, and the source code is freelyavailable to anyone who wants to use and contribute to it.
At the time it was a great example of form following function, like my first car.It ran, it was reliable, but it wasnt pretty, and it needed a lot of customwiggling of this and jiggling of that to keep going. Running a Linux system backthen meant learning your way around a hodgepodge of commands, scripts, andconfiguration files, and a fair bit of wiggling and jiggling. Software management, storage management, networking, audio, video, kernel management, process managementeverything required a lot of hands-on work and continual study.
Some 17 years later, every important subsystem in Linux has substantially changedand improved. Now all those manual chores we had to do for basic administrationare replaced by what I call It Just Works Subsystems. Every aspect of runninga Linux system is many times easier, and we can focus on using Linux to do coolthings instead of having to wiggle and jiggle this and that just to keep itrunning.
I am delighted to present this greatly updated Linux Cookbook second edition,and I hope you enjoy learning about all of this cool new goodness.
Who Should Read This Book
This book is for people with some computer experience, though not necessarily Linuxexperience. Ive done my best to make it as accessible as possible for Linuxbeginners. You should understand some basic networking concepts, such as IP addressing,Ethernet, WiFi, client, and server. You should know basic computer hardwareand have some understanding of using the command line. If you need some helpwith these, there are abundant resources for learning them; I did not want to getbogged down in teaching material that is already well documented.
The recipes in this book are hands-on. My goal is for the reader to be successfulon the first try, though dont feel badly if you are not. A general-purposeLinux computer is an extremely complex machine, and there is a lot to learn. Bepatient, take your time, and read more than you want to. Chances are the answersyou want are just a few sentences away.
Every Linux has built-in documentation for commands called man pages (short for manual pages).For example, man 1 ls documents the ls, or list directory contents, command. Type these commands exactly as shown in the book to open the correct man page. You can also find this information online.
Why I Wrote This Book
I have long wanted to write a book like this, that collects what I think are themost necessary Linux skills in one book. Linux is everywhere, and no matter whereyou find it, Linux is Linux, and the needed skills are the same. The tech worldmoves fast, and I think you will find this book provides a solid foundation thatyou can build on, no matter what direction your interests take you.
The cookbook format is especially good for teaching fundamentals because it showshow to solve specific real-world problems and separates the wordy explanationsfrom the steps needed to accomplish a task.
Navigating This Book
This book is not a formal training course, where you start at the beginning andwork your way to the end. Instead, you can jump in anywhere and hopefully findwhat you need.
It is roughly organized like this:
Chapters cover installing Linux, managing the bootloader, stopping and starting, and answer the Where do I get Linux and how do I make it go questions.
provides an introduction to managing services with systemd, which isa big improvement from the old way of having to learn all manner of scripts,configuration files, and commands.
covers backups and recovery. These threechapters are fundamental to system operations and security.
Chapters are all about partitioning and filesystems, which arefundamental to managing data storage. Data management is the most importantaspect of computing.
is fun. This chapter is about finding detailed information about your computer hardwarewithout opening the case. Modern PC hardware self-reports a lot of information,and Linux supplements this self-reporting with databases of additional information.
Chapters introduces the excellent firewalld, the dynamic firewall that easily handles allkinds of complicated scenarios, like roaming between different networks andmanaging multiple network interfaces.
introduces new features in CUPS, the Common Unix Printing System,including driverless printing, which is especially good for mobile devicesbecause they can connect to a printer without having to download a lot of software .
shows how to control your own LAN name services with the excellentDnsmasq. Dnsmasq has stayed current with support for new protocols, and the oldcommands and configuration options have not changed. It is a first-rate nameserver that seamlessly integrates DNS and DHCP for central management of IPaddressing and advertising network services.