Do you need tools for making your system administration work easier and more efficient? Youve come to the right place.
Perl is a powerful programming language that grew out of the traditional system administration toolbox. Over the years it has adapted and expanded to meet the challenges of new operating systems and new tasks. If you know a little Perl, and you need to perform system administration tasks, this is the right book for you. Readers with varying levels of both Perl programming experience and system administration experience will all find something of use within these pages.
Whats New in This Edition?
A tremendous amount of work went into updating this book so it could be even better than the first edition. Heres some of what has been improved in the second edition:
New title
My editors and I realized that the material in this book was more about how to automate your system administration work in ways that would make your working life more efficient and pleasant than it was about Perl. While Perl is still the toolshed that makes all this possible, it isnt the main focus of the book.
New material
Its hard to know where to begin on this one. The new edition is four chapters and two appendixes bigger (with a total page count that is 50% greater) than the last one. Included in this edition are a cornucopia of new tools and techniques that you are going to love. I tried to add material on the things I wished I had sysadmin-targeted material on, including: XML and YAML best practices (using XML::LibXML
, XML::Twig
, and XPath); dealing with config files; more advanced LDAP topics ( including updated Net::LDAP
information); email-related topics (including POP3/IMAP, MIME, and spam); new ways of dealing with filesystems; more advanced log file creation and parsing tools; DHCP; mapping/monitoring a network using Nmap and other tools; packet creation and sniffing; information reporting using tools like GraphViz, RRDtool, and Timeline; using SHA-2 instead of MD5; SNMPv3; Mac OS X; converting VBScript code to Perl; geocoding; MP3 file manipulation ; using Google Maps; and so on.
New advice
Part of the value of this book is the advice you can pick up from an experienced system administrator like me who has been doing this stuff for a long time and has compared notes with many other seasoned veterans. This new edition is packed with more sidebars to explain not only the what , but also the why behind the material.
Operating system and software information updates
All of the text and code has been updated and augmented to work with the latest versions of Unix- (including Linux and Mac OS X) and Windows-based operating systems.
Module and code updates/improvements
The descriptions and code in this book match the latest versions of the modules mentioned in the first edition. In cases where a module is no longer available or a better alternative has emerged, the appropriate replacement modules have been substituted. Also, all example code is now use strict friendly.
Errata corrected
I have attempted to address all of the errata I received from all of the printings of the first edition. I appreciate the time readers took to report errors to OReilly and me so I could fix them at each printing and in this edition. Special thanks go to Andreas Karrer, the German translator for the first edition. Andi pored over every single byte of the original text and submitted almost 200 (mostly layout-related) corrections, all with good cheer.
How This Book Is Structured
Each chapter in this book addresses a different system administration domain and ends with a list of the Perl modules used in that chapter and references to facilitate deeper exploration of the information presented. The chapters are as follows:
This introductory chapter describes the material covered in the book in more detail, explaining how it will serve you and what you need to get the most from it. The material in this book is powerful and is meant to be used by powerful people (e.g., Unix superusers and Windows-based operating system administrators). The introduction provides some important guidelines to help you write more secure Perl programs.
This chapter is about keeping multiplatform filesystems tidy and ensuring that they are used properly. Well start by looking at the salient differences between the native filesystems for each operating system. Well then explore the process of intelligently walking or traversing filesystems from Perl and how that can be useful. Finally, well look at manipulating disk quotas from Perl.
This chapter discusses how user accounts manifest themselves on two different operating systems, including what is stored for each user and how to manipulate the information from Perl. That leads into a discussion of a rudimentary account system written in Perl. In the process of building this system, well examine the mechanisms necessary for recording accounts in a simple database, creating these accounts, and deleting them.
explores ways to automate tasks centered around user activity, introducing a number of ways to track and control process, file, and network operations initiated by users. This chapter also presents various operating system- specific frameworks and tools (e.g., Windows Management Instrumentation, GUI setup tools, lsof , etc.) that are helpful for user-oriented tasks on different platforms.
Name and configuration services allow hosts on a TCP/IP network to communicate with each other amicably and to self-configure. This chapter takes a historical perspective by starting with host files, then moving on to the Network Information Service (NIS) and finally to the glue of the Internet, the Domain Name Service (DNS). Each step of the way, it shows how Perl can make professional management of these services easier. Well also explore how to work with the Dynamic Host Configuration Protocol (DHCP) from Perl in this chapter.
Almost every system or software package we touch relies heavily on configuration files to be useful in our environment. This chapter explores the tools that make writing and reading those files from Perl easy. Well look at various formats, with special attention paid to XML and the current best practices for working with it using Perl.
Over time, more uses for relational databases are being found in the system administration realm. As a result, system administrators need to become familiar with SQL database administration. This chapter explains DBI, the preeminent SQL database framework for Perl, and provides examples of it in action for database administration .