Python在Unix和Linux系統(tǒng)管理中的應用

出版時間:2009-4  出版社:開明出版社  作者:(美)瓊斯,(美)吉夫特 著  頁數(shù):433  字數(shù):483000  
Tag標簽:無  

前言

  Conventions Used in This Book .  The following typographical conventions are used in this book:  Italic  Indicates new terms, URLs, email addresses, filenames, and file extensions.  Constant width  Used for program listings, in text to refer to program elements, such as variable or function names, databases, data types, environment variables, statements, utilities,keywords, utilities, and modules.  Constant width bold  Shows commands or other text that should be typed literally by the user.  Constant width italic  Shows text that should be replaced with user-supplied values or by values deter-mined by context.  Using Code Examples  This book is here to help you get your job done. In general, you may use the code that is included in this book in your programs and documentation. You do not need to contact us for permission unless youre 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 OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission; incorporating a significant amount of ex-ample code from this book into your products documentation does require permission.We appreciate, but do not require, attribution. An attribution usually includes the title,author, publisher, and ISBN, for example: "Python for Unix and Linux System Admin-istration by Noah Gift and Jeremy M. Jones. Copyright 2008 Noah Gift and Jeremy M.Jones, 978-0-596-51582-9."  If you feel your use of code examples falls outside fair use or the permission given above,feel free to contact us at permissions@oreilly.com.  Safar Books Online  When you see a Safari Books Online icon on the cover of your favorite technology book, that means the book is available online through the OReilly Network Safari Bookshelf.  Safari offers a solution thats better than e-books. Its 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.  How to Contact Us  Please address comments and questions concerning this book to the publisher:  We have a web page for this book, where we list errata, examples, and any additional  To comment or ask technical questions about this book, send email to:  bookquestions@oreilly.com  For more information about our books, conferences, Resource Centers, and the OReilly Network, see our website at:   Acknowledgments  Noahs Acknowledgments  As I sit writing an acknowledgment for this book, I have to first mention Dr. Joseph E.Bogen, because he made the single largest impact on me, at a time that it mattered the most. I met Dr. Bogen while I was working at Caltech, and he opened my eyes to another world giving me advice on life, psychology, neuroscience, math, the scientific study of consciousness, and much more. He was the smartest person I ever met, and was some-one I loved. I am going to write a book about this experience someday, and I am sad-dened that he wont be there to read it, his death was a big loss.  I want to thank my wife, Leah, who has been one of the best things to happen to me,ever. Without your love and support, I never could have written this book. You have the patience of a saint. I am looking forward to going where this journey takes us, and I love you. I also want to thank my son, Liam, who is one and a half, for being patient with me while I wrote this book. I had to cut many of our guitar, piano, and pushup lessons short, so I owe you payback times two, little goat.  To my mom, I love you, and thank you for encouraging me throughout life.  Of course, ! want to thank Jeremy M. Jones, my coauthor, for agreeing to write this book with me. I think we were a great team with different, but complementary styles,and we wrote a great book. You have taught me a lot about Python, and have been a good partner and friend. Thanks!  Titus Brown, whom I suppose I have to call Dr. Brown now, was the person that got me interested in Python to begin with, when I met him at Caltech. He is another ex-ample of how one person can make a difference, and I am glad to consider him an "old"friend, the kind money cant buy. He kept asking me, "Why dont you use Python?"And then one day I did. If it wasnt for Titus, I would certainly have continued down the Java and Peri path. You can read his blog here: http://ivory, idyll.org/blog.  Shannon Behrens has a heart of solid gold, a mind as sharp as a razor, and a knowledge of Python that is truly scary. I first met Shannon through Titus, ironic again, but he and I became quick friends. Shannon is the real deal in every sense of the word, and has taught me a tremendous amount about Python, in fact, staggering would be a better word. His help with Python, and editing this book has been incredible, and I owe him tremendously. I shudder to think of what it would have looked like without him. I cant ever imagine a company being foolish enough to let him get away, and I look forward to helping him with his first book. Finally, he is just an incredible technical reviewer.You can read his blog here: http://jjinux, blogspot, com/.  Doug Hellmann was our other star technical reviewer and was exceptionally productive and helpful. Jeremy and I are extremely fortunate to get someone of his caliber to review the book. He went above and beyond his call of duty, and is truly a force of efficiency to reckon with. He was also a great source of motivation while we worked together at Racemi. You can read his blog here: http//blog, dougheUmann.com/.  Thanks to Scott Leerseen for reviewing our book and giving us good advice along the way. I also especially enjoyed our code review battles. Just remember, I am always right.Thanks to Alfredo Deza for the work on making an Ubuntu virtual machine for the book, your expertise was greatly appreciated.  A very large thanks to Liza Daly, for providing good feedback on some really early, and rough, parts of our book. This was tremendously helpful..  Special thanks to Jeff Rush for his advice and reference material on Buildout, Eggs, and Virtualenv.  Thanks to Aaron Hillegass who has given me some great advice and help along the way,and who has a great training company, Big Nerd Ranch. He is a special person, who I am lucky to have met. Thanks to Mark Lutz, who I had the pleasure of taking a Python training course from, and who has written some great books on Python.  Thanks to the people in the Python community in Atlanta, and the members of PyAtl:kttp://pyatl.org; you have all taught me a great deal. Rick Copeland, Rick Thomas,Brandon Rhodes, Derek Richardson, Jonathan La Cour, a.k.a Mr. Metaclass, Drew Smathers, Cary Hull, Bernard Matthews, Michael Langford, and many more I have forgotten to mention. Brandon and Rick Copeland in particular have been very helpful and are awesome Python programmers. You can read Brandons blog at http://rhodes mill. or g/br andon/.  Thanks to Grig Gheorgbiu for giving us expert sysadmin and testing advice and for giving us a kick in the butt when we needed one.  Thanks to my former employer Racemi, and the CTO/Founder, Charles Watt. I learned a lot from you and was glad you knew which competitive buttons to push. Just re-member I will kick your butt at writing code, a 26-mile run, or a 200-mile bike ride any day, just tell me where and when.  Thanks to Dr. Nanda Ganesan, who was a great mentor in graduate school at CSULA.You taught me a lot about information technology and life and encouraged me to think big.  Thanks to Dr. Cindy Heiss, who was my professor for my undergraduate degree in nutritional science. You got me started on web development, encouraged me to believe in myself, and ultimately made an impact on my life, thanks!  Thanks to Sheldon Blockburger, who let me try out for Division I decathlon as a walk-on at Cal Poly SLO. Even though I didnt make the team, you showed me how to be a fierce competitor and warrior, and taught me the self-discipline to run 200-meter in-tervals by myself. I believe weekly 200-meter interval workouts make me a better soft-ware engineer.  There were many other people who helped tremendously along the way, including Jennifer Davis, yet another friend from Caltech, who gave us some great feedback; some of my friends and coworkers at Turner; Doug Wake, Wayne Blanchard, Sam Allgood,Don Voravong; some of my friends and coworkers from Disney Feature animation,including Sean Someroff, Greg Neagle, and Bobby Lea. Greg Neagle in particular taught me a lot about OS X. Also, thanks to J.F. Panisset, who I met at Sony Imageworks, for teaching me quite a bit about engineering in general. Although he is now a CTO, he is another rare catch for any company.  I would like to thank a few others who made some important contributions: Mike Wagner, Chris McDowell, and Shaun Smoot.  Thanks to Bruce J. Bell, who I worked with at Caltech. He taught me quite a bit about Unix and programming over the years, and I owe him greatly for it. You can read his material here: http://www, ugcs. caltech, edu/-bruce/.  Also thanks to Alberto Valez, my boss at Sony Imageworks, for being possibly the best boss I ever had and giving me the chance to completely automate my job. Thanks to film editor Ed Fuller, who helped with advice on the book, and was a good friend during this process.  Thanks to many people in the Python community. First, thanks to Guido van Rossum for writing a great language, for being a great leader, and for being patient with me when I asked for advice on the book. There are so many rock stars in the Python com-munity who crank out useful tools that I use everyday. They include Ian Bicking, Fer-nando Perez and Villi Vainio, Mike Bayer, Gustavo Niemeyer, etc. Thanks! Thanks to the great book by David Beazely, and his fantastic tutorial at PyCon 2008 on Genera-tors. Thanks to other writers about Python and systems administration as well. You can find links to their work here: http://wiki.python.org/rnoin/systemsadministration.Thanks also to the Repoze crew: Tres Seaver and Chris McDonough (http://repoze.org/index, html).  Special thanks to the great tools, advice, and tolerance from Phillip J. Eby on the setuptools section. Also, thanks to Jim Fulton who tolerated my questions about ZODB and buildout, with a crazy schedule. Additional thanks to Martijn Fassen, who taught me about ZODB and Grok. If you want to see the future of Python web development,check out Grok: http://grok.zope, org/.  Thanks to Red Hat Magazine staff, Julie Bryce, Jessica Gerber, Bascha Harris, and Ruth Suehle, for letting me try out ideas we used in this book in the form of articles. Also,thanks to Mike McCrary at IBM Developerworks, for letting me write articles to try out ideas we used in this book.  I want to thank the multitudes of people who told me at one point in my life that I couldnt do something. At almost every step, I have met discouraging people who told me everything from I would never get into the college I wanted to to I would never learn to program. Thank you for giving me the extra motivation to succeed at my dreams.Humans can create their own reality if they truly believe in themselves, and I would encourage everyone to give themselves a chance to do what they truly want to do.  Finally, thanks to OReilly and Tatiana Apandi, for believing in my original pitch for a book on Python and Systems Administration. You took a chance and believed in me and Jeremy, and I thank you for that. Although Tatiana left OReilly near the end of our book to pursue her dreams, her impact was still felt. I also want to thank our new editor Julie Steele, who has been supportive and helpful every step of the way. You have really provided a sea of calm that I personally appreciated greatly. I look forward to hearing great things in the future from Julie, and Im excited to work with her again.  Jeremys Acknowledgments  After reading Noahs list of thanks, it makes me feel both ungrateful, because I know my list wont be that long, and at a loss, because I think he covered nearly everyone that I wanted to thank.  First, I must thank my God, through Whom I can do all things and without Whom, I can do nothing.  First in an earthly sense, I thank my wife, Debra. You kept the children engaged with other activities while I worked on the book. You enforced the so-often reapeated rule "Dont bother Daddy while hes working on his book." You encouraged me when I needed it, and you also gave me a lot of space, which is what I needed most. Thank you. I love you. I could not have written this book without you.  I also must thank my sweet children, Zane and Justus, for their patience through the process of my writing this book. I missed out on a lot of trips to Stone Mountain with you both. I still put one of you to bed most nights, but I missed out on staying in there long enough to fall asleep with you, like I used to. I missed out on the last several weeks of Kids Rock on Wednesday nights. I missed out on so much, but you bore it patiently.So, thank you for your patience. And thank you for your excitement as you hear that Im almost done with the book. I love you both.  I want to thank my parents, Charles and Lynda Jones, for their support through the course of my writing this book. But more than that, I want to thank them for being a living example of a strong work ethic, of earning everything you have, of working hard to better yourself, and of spending money wisely. Those are lessons I hope to pass on to Zane and Justus.  Thank you to Noah Gift, my coauthor, for getting me into this mess. It has been hard,harder than I thought and definitely one of the hardest things Ive ever done in my life.I think it says a lot about a person when you work on something like this with him and at the end, you can still think of him as your friend. Thanks, Noah. This book would not have begun if not for you.  I want to thank our team of reviewers. I think that Noah has already thanked all of you,but I want to thank everyone that I can: Doug Hellman, Jennifer Davis, Shannon JJ Behrens, Chris McDowell, Titus Brown, and Scott Leerseen. You guys were awesome.There were times when I thought that I had something spot-on and you readjusted my thinking. Or you just brought a completely different perspective to the book and helped me see my work through a different set of eyes. (That was mostly you, Jennifer. If the text processing chapter is useful for sysadmins, its mostly because of you.) Thank you all.  I also want to thank our editors, Tatiana Apandi and Julie Steele. You guys handled the hard stuff, freeing us up to work on the book. You both eased our burden along the way. Thank you.  Id also like to thank Fernando Perez and Ville Vainio for your amazing feedback. I hope Ive done IPython justice. And thank you for IPython. 1 feel like I couldnt live without it.  Thank you Duncan McGreggor, for helping me get the Twisted code in better shape.Your comments were extemely helpful. And thank you for working on Twisted. It is an amazing framework. I hope to use it more, real soon now.  I thank Bram Moolenaar and everyone who has ever worked on the Vim editor. Almost every word and XML tag that I wrote flowed through capabilities Vim. I picked up a few tricks along the way that Ill incorporate into my daily editing habits. Vim made me more productive. Thank you.  I also want to thank Linus Torvalds, the Debian folks, the Ubuntu folks, and anyone else who has ever worked on kinux. Almost every word that I typed was done on Linux.You made it incredibly simple to set up new environments and test different things.Thank you.  Finally, but by no means least, I want to thank Guido van Rossum and everyone who has ever done any work on Python. I have been benefitting from your work for a number of years now. I was hired for my last two jobs because of Python. Python, the language,and Python, the community, have been both a great joy for me since I started working with it sometime around 2001-2002. Thank you. Python has been very good to me.

內容概要

《Python在Unix和Linux系統(tǒng)管理中的應用》展示了Python語言如何提供一種更加高效的方式來處理Unix和Linux服務器管理工作中的各種任務。本書的每一章都會提出一個特定的管理問題,例如并發(fā)或數(shù)據(jù)備份,然后通過實際的例子提供基于Python的解決方案。你將學習使用Python開發(fā)一套屬于自己的命令行工具,并用來解決一系列范圍很廣的問題?! ”緯髡邆冞€構建了一個可以免費下載的Ubuntu虛擬機。該虛擬機包含了這本書的源代碼,還可以用來運行書中的實例,包括SNMP、IPython、SQLAlchemy和許多其他工具。  通過這本書,你將發(fā)現(xiàn)Python是怎樣幫助你: ·讀入文本文件并提取信息 ·使用線程和派生子進程的選項并發(fā)地運行多個任務 ·使用網(wǎng)絡工具從一個進程傳送信息到另一個進程 ·創(chuàng)建更易互動的可點擊圖形界面工具 ·通過與SNMP交互來用程序監(jiān)控大型多個集群機器 ·掌握IPython的命令環(huán)境來替代或增強Bash、Korn或Z-Shell的功能 ·將云計算集成到基礎架構中并編寫一個基于谷歌應用程序引擎的應用 ·利用定制腳本來解決特殊的數(shù)據(jù)備份的挑戰(zhàn) ·使用Django、SQLAlchemy和Storm對象關系模型來與數(shù)據(jù)庫交互  通過本書及其輔助虛擬機,你將學習如何打包并部署Python應用程序和庫文件,以及如何編寫在多個Unix和Linux平臺下都運行良好的代碼。

作者簡介

Noah Gift在加州理工學院、迪斯尼、Feature Animation和Turner Studios具有十年以上的Unix和Linux開發(fā)經驗。他是Giftcs和Cloud Seed軟件公司的合伙人。
  Jeremy M.Jones是Predictix公司的軟件工程師,同時也是開源項目Munkware、ediplex和podgrabber的作者。

書籍目錄

ForewordPreface1.Introduction Why Python? Motivation The Basics Executing Statements in Python Using Functions in Python Reusing Code with the Import Statement2.IPython   Installing IPython Basic Concepts Help with Magic Functions Unix Shell Information Gathering Automation and Shortcuts Summary 3.Text  Python Built-ins and Modules  Log Parsing  ElementTree  Summary 4.Documentation and Reporting  Automated Information Gathering  Manual Information Gathering  Information Formatting Information Distribution Summary5.Networking Network Clients Remote Procedure Call Facilities SSH Twisted Scapy Creating Scripts with Scapy6.Data Introduction Using the OS Module to Interact with Data Copying, Moving, Renaming, and Deleting Data Working with Paths, Directories, and Files Comparing Data Merging Data Pattern Matching Files and Directories Wrapping Up rsync Metadata: Data About Data Archiving, Compressing, Imaging, and Restoring Using tarfile Module to Create TAR Archives Using a tarfile Module to Examine the Contents of TAR Files7.SNMP Introduction Brief Introduction to SNMP IPython and Net-SNMP Discovering a Data Center Retrieving Multiple-Values with Net-SNMP Creating Hybrid SNMP Tools Extending Net-SNMP SNMP Device Control Enterprise SNMP Integration with Zenoss8.OS Soup Introduction Cross-Platform Unix Programming in Python Pylnotify OSX Red Hat Linux Systems Administration Ubuntu AdministrationSolaris Systems AdministrationVirtualizationCloud ComputingUsing Zenoss to Manage Windows Servers from Linux9.Package Management10.Processes and Concurrency11. BuildingGUIs.12. Data Persistence13.Command Line14.Pragmatic ExamplesAppendix: CallbacksIndex

章節(jié)摘錄

  As I sit writing an acknowledgment for this book, I have to first mention Dr. Joseph E. Bogen, because he made the single largest impact on me, at a time that it mattered the most. I met Dr. Bogen while I was working at Cahech, and he opened my eyes to another world giving me advice on life, psychology, neuroscience, math, the scientific study of consciousness, and much more. He was the smartest person I ever met, and was someone I loved. I am going to write a book about this experience someday, and I am saddened that he wont be there to read it, his death was a big kiss.I want to thank my wife, Leah, who has been one of the best things to happen to me, ever. Without your love and support, I never could have written this book. You have the patience of a saint. I am looking forward to going where this journey takes us, and I love you. I also want to thank my son, Liam, who is one and a half, for being patient with me while I wrote this book. I had to cut many of our guitar, piano, and pushup lessons short, so I owe you payback times two, little goat.To my morn, I love you, and thank you for encouraging me throughout life. Of course, 1 want to thank Jeremy M. Jones, my coauthor, for agreeing to write this book with me. I think we were a great team with different, but complementary styles, and we wrote a great book. You have taught me a lot about Python, and have been a good partner and friend. Thanks!Titus Brown, whom I suppose I have to call Dr. Brown now, was the person that got me interested in Python to begin with, when I met him at Caltech. He is another ex ample of how one person can make a difference, and I am glad to consider him an "old" friend, the kind money cant buy. He kept asking me, "Why dont you use Python?" And then one day I did. If it wasnt for Titus, I would certainly have continued down the Java and Perl path. You can read his blog here: http://ivory.idyll.org/blog. Shannon Behrens has a heart of solid gold, a mind as sharp as a razor, and a knowledge of Python that is truly scary. I first met Shannon through Titus, ironic again, but he and I became quick friends. Shannon is the real deal in every sense of the word, and has taught me a tremendous amount about Python, in fact, staggering would be a better word. His help with Python, and editing this book has been incredible, and t owe him tremendously. I shudder to think of what it would have looked like without him. I cant ever imagine a company being foolish enough to let him get away, and I look forward to helping him with his first book. Finally, he is just an incredible technical reviewer.

媒體關注與評論

  “這本書適用于Python新手,不管他們是否具有命令環(huán)境腳本編寫的經驗或者總體上相對而言就是編程初學者。Jeremy和Noah都很注意為自己的理由給出支持材料,并且解釋這些代碼實例在實際中的運用。與許多輕易就讓新手不堪重負的編程書籍不同,本書盡一切努力來讓這些新手們獲得自信和成功?!薄  猂uth Suehle和Bascha Harris,Red Hat雜志

圖書封面

圖書標簽Tags

評論、評分、閱讀與下載


    Python在Unix和Linux系統(tǒng)管理中的應用 PDF格式下載


用戶評論 (總計4條)

 
 

  •   如題,但是有一點,買書的時候要買中文版,我當時購買了英文版,看的我頭暈眼花,后來找到中文版的電子書,讀后受益匪淺啊,建議python的程序員或者有志于系統(tǒng)管理的人員一定要閱讀此書。
  •   對于Python有一定基礎,想在Linux系統(tǒng)下進一步配置運用,是一本很好的書,比較全面詳細認真。
  •   這本書還是很好的,linux管理比較全,復習了很多腳本知識
  •   本想買本中文版的,發(fā)現(xiàn)時影印的。。。哎。。不知有沒有心情去讀。
 

250萬本中文圖書簡介、評論、評分,PDF格式免費下載。 第一圖書網(wǎng) 手機版

京ICP備13047387號-7