Preface

Both authors of this book have been system administrators for a while. When the opportunity to write this book came about, we initially focused on cool hacks we’d developed or used in our server and system administration careers. We also asked friends, who asked their friends, and we were therefore able to get some great contributions from others to augment the things that we’d come up with. Everybody has problems they like to solve. Bill likes distributed authentication, undeleting and recovering files, and tweaking filesystems in general. Brian likes making admin tasks more efficient, reliable, and repeatable; has a bucketload of cool scripts to do various tasks; and loves getting and using data from remote sources. And every sysadmin has favorite techniques for solving problems, so Hack is to Hacker as Cool Tip or Technique is to Server or System Administrator. Sysadmin hacks are essentially clever ways of approaching whatever problem you’re trying to solve, whether it’s figuring out how to recover lost data, trying to collect information from distributed clients in one place so that you can easily see the big picture or anything else that comes up.

As we worked on this book, thinking about cool server and sysadmin hacks mutated into thinking about general tips and tricks that we found useful to simplify our lives as system administrators. We also noticed that there weren’t really any books available along the lines of “Things We Wish Previous System Administrators Had Told Us.” Leaving aside obvious questions like “where is the key to the RAID array” and “what was the root password on <insert hostname here>,” we decided to “hack the Hacks series” a bit and incorporate some general sysadmin information, tips, and tricks as another of this book’s primary themes. This means that we provide a bit more background material than you ordinarily see in Hacks books. You’re not going to hurt our feelings if you skip over things you already know, but we hope that all the material will be found useful by some of our readers. We could have used it years ago, and as Mr. Rogers used to say, “It’s nice to share.”

Sometimes, too much software and too many choices can be a problem. Should we use MTRG, Ethereal, EtherApe, or some other application to monitor network traffic? Should we create logical volumes using linear RAID, LVM, LVM2, or EVMS? Should we do our resumes in TeX, LaTeX, troff, lout, SGML, or XML? You get the idea. If you need to solve a problem but don’t know what tool to select from among the myriad choices available, you can spend exponentially more time selecting the right software and ramping up than you do actually solving the problem. For that reason, a book on task-oriented solutions to common problems has been a lot of fun to write, and it should save you many an overnight Google session—as well as providing information that works together and is up to date at the time of writing. All the hacks in this book are techniques that we’ve used at various times and that we view as time-and hassle-savers that are usually downright fun and cool.

Aside from the “too much software” issue just mentioned, a related concept (and the deep, dark secret of open source) is that not all open source projects are “finished”—ever. (For God’s sake, don’t tell Microsoft!) Not only do you have many, many choices in the open source space, but the ones you find may do only 95% of what you want, missing on the truly critical 5%. Though there’s a lot of really cool-looking, whizzy open source software out there, sometimes the zip gun that reliably fires one bullet using a rubber band is preferable to the chromed fusion-powered death ray that works only 75% of the time—thus books like this one, in which people explain how to accomplish things using packages they’ve actually used and often still depend on, even if the packages aren’t perfect. The tools discussed in these hacks are generally good additions to anyone’s toolbox/ library of tips and tricks—and we’ll show you how to use them for a variety of purposes.

Again, rather than just explaining how to do specific tasks, we’ve tried to provide a little background and context for our approach. This is a book of hacks, but you deserve a little bit of extra info to put the hacks, tools, and solutions in the right context. Where possible, we’ve also identified other packages and procedures that may accomplish the same goal, but we focus on our preferred solutions for different types of problems.

Why Linux Server Hacks, Volume Two?

The term hacking has a bad reputation in the press, where it used to refer to someone who breaks into systems or wreaks havoc, using computers as their weapon. Among people who write code, though, the term hack refers to a “quick-and-dirty” solution to a problem or a clever way to get something done. And the term hacker is taken very much as a compliment, referring to someone as being creative, having the technical chops to get things done. The Hacks series is an attempt to reclaim the word, document the good ways people are hacking, and pass the hacker ethic of creative participation on to the uninitiated. Seeing how others approach systems and problems is often the quickest way to learn about a new technology.

Linux Server Hacks, Volume Two came about because today’s sysadmins need to deal with a vast number of situations, operating systems, software packages, and problems—and also because our original title, Son of Linux Server Hacks, was rejected. The original Linux Server Hacks is a great book—both authors owned it before starting this project—but there are many more hacks, cool tips, and ways of resolving problems that sysadmins face than can fit in a single volume (one that mere mortals can lift, that is). The power and flexibility of Linux means that there is an incredible amount of great Linux software out there, waiting to solve your sysadmin problems—if you know about it. Hence Linux Server Hacks, Volume Two. This book discusses some of our favorite software packages, how to use them to make your life as a sysadmin easier, how to best keep all the systems you’re responsible for up and running smoothly, and how to keep your users happy (even if they may not know or appreciate just how wizardly you’ve been).

How to Use This Book

You can read this book from cover to cover if you like, but each hack stands on its own, so feel free to browse and jump to the different sections that interest you most. If there’s a prerequisite you need to know about, a cross-reference will guide you to the right hack. We’ve also tried not to be shy or “our book"-centric—if there are other books on a topic that we particularly like or find valuable, we’ve put references to them at the end of the hack. Some of them are other books from O’Reilly, but we’re not recommending them for any reason other than the fact that we’ve found them to be useful. We only recommend what we believe in.

How This Book Is Organized

This book is divided into 10 chapters, organized by subject:

Chapter 1, Linux Authentication

Use the hacks in this chapter to explore the authentication options that are available to you in heterogeneous networked computing environments and simplify administering user accounts and passwords. This chapter also provides some quick and dirty tips for those unfortunate moments when, for one reason or another, you have to lock users out of specific systems quickly.

Chapter 2, Remote GUI Connectivity

This chapter explores ways of connecting to remote systems. When you just can’t be everywhere at once, it’s incredibly useful to be able to access multiple consoles and graphical displays from the convenience of your office or machine room. You’ll find many of the hacks in this chapter to be handy tips that you may want to pass on to your users who also need to work on multiple systems, regardless of what operating systems they’re running.

Chapter 3, System Services

Networks make it easy to set up servers on specific systems to address the needs of clients throughout your computing environment. The hacks in this chapter explain how to set up central servers that do things like synchronize the time on all the systems in your environment (via NTP), deliver IP addresses to newly connected hosts (using DHCP), and integrate these services with existing ones (with DHCP and name lookups done via DNS, for example). This chapter also discusses setting up centralized access to printers from both sides—how to set up your print servers, and how to access them from the various operating systems that your users may have running on their desktops.

Chapter 4, Cool Sysadmin Tools and Tips

This chapter presents a variety of cool sysadmin tips and techniques that we’ve accumulated over the years, including how to keep processes running without writing a daemon or staying logged in, how to use PXE to netboot Linux, how to share information with fellow sysadmins in a centralized fashion, how to get the most out of classic but incredibly useful terminal-oriented applications (such as minicom, screen, and vi), and so on. We also discuss how to quickly and easily create documentation for your sysadmin policies and procedures so that your successors can figure out how things work after Google hires you away from your current employer.

Chapter 5, Storage Management and Backups

If everything just kept running forever, storage was infinite, and users never executed the rm command with the wrong arguments, this chapter would be unnecessary. Welcome to Earth! Things don’t actually work that way. However, the hacks in this chapter explore some cool ways of making it easier for you to manage storage, deploy new systems, do backups of today’s huge disks, and even reduce the need for some of the restore requests that occasionally clog every sysadmin’s inbox.

Chapter 6, Standardizing, Sharing, and Synchronizing Resources

Networked computing environments make it easy to store data on different machines or on centralized servers. This chapter provides some tips and tricks for managing distributed storage and making sure the administrative environments on your servers are synchronized.

Chapter 7, Security

Security is not just a job; it’s an adventure with no end in sight. Crackers are always working on new ways to break into existing networks and machines, and you need to be able to either lock them out or at least understand what they’ve broken when they get in. The hacks in this chapter discuss a wide range of security tools and techniques that can help you sleep at night and protect your systems at the same time.

Chapter 8, Troubleshooting and Performance

This chapter provides techniques for optimizing system performance, whether by figuring out who’s hogging the entire CPU and shooting down that user’s nethack sessions or by using cool knobs in the /proc filesystem to tweak system performance or using journaling filesystems to minimize system restart time. It also provides some useful X hacks, such as an easy way to use multiple monitors on a single system and a discussion of reducing desktop overhead by punting GNOME or KDE in favor of simpler X Window managers that eliminate CPU-intensive bells and whistles and actually just manage windows.

Chapter 9, Logfiles and Monitoring

Logfiles aren’t just a diary for your system and its core applications; they are a useful record that you can use to spot emerging problems so you can correct them before they mature into catastrophes. This chapter includes hacks that enable you to centralize log information in a variety of ways, be warned when problems arise, and get the most out of system status information, whether it’s log information, internal disk controller status data, or remote hardware status information that you can collect via SNMP. It also discusses tools for monitoring your network and spotting the BitTorrent user who’s slowing down your CEO’s web browsing.

Chapter 10, System Rescue, Recovery, and Repair

Sooner or later, some system that you’re responsible for will go down. If you can’t fix your problems by board-swapping, the hacks in this chapter will show you how to boot crippled systems so that you can diagnose problems, repair munged filesystems, and even (if you’re lucky) recover deleted files or data that was stored on disks that have gone belly up. Try the tips and tricks in this chapter if you’re having problems—there’s always plenty of time to panic later.

Conventions Used in This Book

The following is a list of the typographical conventions used in this book:

Italics

Used to indicate URLs, Unix utilities, filenames, filename extensions, and directory/folder names. For example, a path in the filesystem will appear as /Developer/Applications.

Constant width

Used to show code examples, the contents of files, and console output, as well as the names of variables, commands, and other code excerpts in the text.

Constant width bold

Used to indicate user input, such as commands to be entered by the user, and to highlight portions of code (typically new additions to old code).

Constant width italic

Used in code examples to show sample text to be replaced with your own values.

Gray type

Used to indicate a cross-reference within the text.

You should pay special attention to notes set apart from the text with the following icons:

Tip

This is a tip, suggestion, or general note. It contains useful supplementary information about the topic at hand.

Warning

This is a warning or note of caution, often indicating that your money or your privacy might be at risk.

The thermometer icons, found next to each hack, indicate the relative complexity of the hack:

beginner moderate expert

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "Linux Server Hacks, Volume Two by Bill von Hagen and Brian K. Jones. © 2006 O’Reilly Media, Inc., 0-596-10082-5.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

How to Contact Us

We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). As a reader of this book, you can help us to improve future editions by sending us your feedback. Please let us know about any errors, inaccuracies, bugs, misleading or confusing statements, and typos that you find anywhere in this book.

Please also let us know what we can do to make this book more useful to you. We take your comments seriously and will try to incorporate reasonable suggestions into future editions. You can write to us at:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the U.S. or Canada)
(707) 829-0515 (international/local)
(707) 829-0104 (fax)

To ask technical questions or to comment on the book, send email to:

The web site for Linux Server Hacks, Volume Two lists examples, errata, and plans for future editions. You can find it at:

http://www.oreilly.com/catalog/morelnxsvrhks/

For more information about this book and others, see the O’Reilly web site:

http://www.oreilly.com

Safari® Enabled

When you see a Safari® Enabled icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.

Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.

Got a Hack?

To explore Hacks books online or to contribute a hack for future titles, visit:

http://hacks.oreilly.com
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.91.187