1000+ commands for opensuse and suse linux enterprise · suse® linux® toolbox: 1000+ commands for...
TRANSCRIPT
SUSELinuxTOOLBOX
1000+ Commands for openSUSE and SUSE Linux Enterprise
Christopher NegusFranois Caen
Wiley Publishing, Inc.
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page iii
File AttachmentC1.jpg
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page ii
SUSELinuxTOOLBOX
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page i
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page ii
SUSELinuxTOOLBOX
1000+ Commands for openSUSE and SUSE Linux Enterprise
Christopher NegusFranois Caen
Wiley Publishing, Inc.
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page iii
SUSE Linux Toolbox: 1000+ Commands for openSUSE and SUSE Linux EnterprisePublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-08292-8Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data is available from the publisher.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or byany means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted underSections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of thePublisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center,222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permis-sion should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis,IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warrantieswith respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties,including without limitation warranties of fitness for a particular purpose. No warranty may be created orextended by sales or promotional materials. The advice and strategies contained herein may not be suitable forevery situation. This work is sold with the understanding that the publisher is not engaged in rendering legal,accounting, or other professional services. If professional assistance is required, the services of a competent pro-fessional person should be sought. Neither the publisher nor the author shall be liable for damages arising here-from. The fact that an organization or Website is referred to in this work as a citation and/or a potential source offurther information does not mean that the author or the publisher endorses the information the organization orWebsite may provide or recommendations it may make. Further, readers should be aware that Internet Websiteslisted in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Departmentwithin the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc.and/or its affiliates, in the United States and other countries, and may not be used without written permission.SUSE and openSUSE are registered trademarks of Novell, Inc. Linux is a registered trademark of Linus Torvalds.All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated withany product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not beavailable in electronic books.
82928ffirs.qxd:Toolbox 11/1/07 12:40 PM Page iv
www.wiley.com
As always, I dedicate my work on this book to my wife, Sheree.
Christopher Negus
I dedicate this book to the UnderLUG crew.
Franois Caen
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page v
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page vi
About the AuthorsChristopher Negus is the author of the best-selling Fedora and Red Hat Linux Bibles,Linux Toys, Linux Troubleshooting Bible, and Linux Bible 2007 Edition. He is a member ofthe Madison Linux Users Group. Prior to becoming a full-time writer, Chris servedfor eight years on development teams for the Unix operating system at AT&T, whereUnix was created and developed. He also worked with Novell on Unix developmentand Caldera Linux.
Franois Caen, through his company Turbosphere LLC, hosts and manages businessapplication infrastructures, with 95 percent running on Linux systems. As an opensource advocate, he has lectured on OSS network management and Internet services,and served as president of the Tacoma Linux User Group. Franois is a Red HatCertified Engineer (RHCE). In his spare time, Franois enjoys managing enterpriseCisco networks.
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page vii
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page viii
CreditsAcquisitions EditorJenny Watson
Development EditorSara Shlaer
Technical EditorThomas Blader
Copy EditorMichael Koch
Editorial ManagerMary Beth Wakefield
Production ManagerTim Tate
Vice President and Executive Group PublisherRichard Swadley
Vice President and Executive PublisherJoseph B. Wikert
Project Coordinator, CoverLynsey Osborn
CompositorLaurie Stewart, Happenstance Type-O-Rama
ProofreaderKathryn Duggan
IndexerMelanie Belkin
Anniversary Logo DesignRichard Pacifico
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page ix
Contents at a GlanceChapter 1: Starting with SUSE . . . . . . . . . . . . . . . . . . . . . . . . .1Chapter 2: Installing openSUSE and Adding Software . . . . . . . .11Chapter 3: Using the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . .41Chapter 4: Working with Files . . . . . . . . . . . . . . . . . . . . . . . . .59Chapter 5: Manipulating Text . . . . . . . . . . . . . . . . . . . . . . . . . .79Chapter 6: Playing with Multimedia . . . . . . . . . . . . . . . . . . . . .97Chapter 7: Administering File Systems . . . . . . . . . . . . . . . . . .111Chapter 8: Backups and Removable Media . . . . . . . . . . . . . . .139Chapter 9: Checking and Managing Running Processes . . . . . .155Chapter 10: Managing the System . . . . . . . . . . . . . . . . . . . . .173Chapter 11: Managing Network Connections . . . . . . . . . . . . .195Chapter 12: Accessing Network Resources . . . . . . . . . . . . . . .215Chapter 13: Doing Remote System Administration . . . . . . . . .235Chapter 14: Locking Down Security . . . . . . . . . . . . . . . . . . . .251Appendix A: Using vi or Vim Editors . . . . . . . . . . . . . . . . . . . .265Appendix B: Shell Special Characters and Variables . . . . . . . .273Appendix C: Getting Information from /proc . . . . . . . . . . . . . .277Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
82928ffirs.qxd:Toolbox 11/1/07 12:31 PM Page x
Contents
Acknowledgments xixIntroduction xxi
Chapter 1: Starting with SUSE 1
About SUSE, Novell, and Linux 2Comparing SUSE to Other Linux Versions 2Finding SUSE Resources 3
Focusing on Linux Commands 4Finding Commands 5Command Reference Information in SUSE 6
Summary 10
Chapter 2: Installing openSUSE and Adding Software 11
Installing openSUSE 11Preparing to Install 12Choosing Installation Options 12Answering Installation Questions 15
Working with Software Packages 18Getting Software Packages with YaST 19Adding and Updating Software with YaST 20Using zypper to Manage Software 23
Working with zypper Repositories 24Searching for Software with zypper 27Installing and Removing Software with zypper 31
Managing Software with RPM 33Installing a Package with rpm 34Upgrading a Package with rpm 34Removing a Package with rpm 35Querying Information about RPM Packages 35Verifying Installed Packages with rpm 38Building RPMs from SRPMs 39Extracting Files from RPMs 40
Summary 40
82928ftoc.qxd:Toolbox 11/1/07 12:32 PM Page xi
xii
Contents
Chapter 3: Using the Shell 41
Terminal Windows and Shell Access 41Using Terminal Windows 41Using Virtual Terminals 43
Using the Shell 44Using Bash History 44Using Command Line Completion 45Redirecting stdin and stdout 46Using alias 49Watching Commands 50Watching Files 50
Acquiring Superuser Power 50Using the su Command 50Delegating Power with sudo 51
Using Environment Variables 52Creating Simple Shell Scripts 54
Editing and Running a Script 54Adding Content to Your Script 54
Summary 58
Chapter 4: Working with Files 59
Understanding File Types 59Using Regular Files 59Using Directories 61Using Symbolic and Hard Links 61Using Device Files 62Using Named Pipes and Sockets 63
Setting File and Directory Permissions 63Changing Permissions with chmod 64Setting the umask 66Changing Ownership 66
Traversing the File System 67Copying Files 68Changing File Attributes 70Searching for Files 71
Finding Files with locate 72Locating Files with find 72
82928ftoc.qxd:Toolbox 11/1/07 12:32 PM Page xii
xiii
Contents
Using Other Commands to Find Files 75Finding Out More About Files 75
Listing Files 75Verifying Files 76
Summary 78
Chapter 5: Manipulating Text 79
Matching Text with Regular Expressions 79Editing Text Files 80
Using the JOE Editor 81Using the Pico and nano Editors 84Graphical Text Editors 86
Listing, Sorting, and Changing Text 86Listing Text Files 87Paging Through Text 88Paginating Text Files with pr 88Searching for Text with grep 89Replacing Text with sed 91Translating or Removing Characters with tr 92Checking Differences Between Two Files with diff 93Using awk and cut to Process Columns 95Converting Text Files to Different Formats 96
Summary 96
Chapter 6: Playing with Multimedia 97
Working with Audio 97Playing Music 97Adjusting Audio Levels 99Ripping CD Music 100Encoding Music 101Streaming Music 103Converting Audio Files 105
Transforming Images 106Getting Information about Images 106Converting Images 107Converting Images in Batches 109
Summary 109
82928ftoc.qxd:Toolbox 11/1/07 12:32 PM Page xiii