BANISH YOUR MOUSE ˆ ˇ THE LINUX ˇ COMMAND LINE

3y ago
69 Views
8 Downloads
8.94 MB
482 Pages
Last View : 18d ago
Last Download : 3m ago
Upload by : Adele Mcdaniel
Transcription

BA NISH YOURMOUSEThe Linux Command Line takes you from your very firstterminal keystrokes to writing full programs in Bash, themost popular Linux shell. Along the way you’ll learnthe timeless skills handed down by generations ofgray-bearded, mouse-shunning gurus: file navigation,environment configuration, command chaining, patternmatching with regular expressions, and more.In addition to that practical knowledge, author WilliamShotts reveals the philosophy behind these tools andthe rich heritage that your desktop Linux machine hasinherited from Unix supercomputers of yore.As you make your way through the book’s short, easilydigestible chapters, you’ll learn how to: Create and delete files, directories, and symlinks Administer your system, including networking,package installation, and process management Use standard input and output, redirection, andpipelines Edit files with Vi, the world’s most popular text editor Write shell scripts to automate common or boring tasks Slice and dice text files with cut, paste, grep, patch,and sedOnce you overcome your initial “shell shock,” you’llfind that the command line is a natural and expressiveway to communicate with your computer. Just don’t besurprised if your mouse starts to gather dust.ABOUT THE AUTHORWilliam E. Shotts, Jr., has been a software professionaland avid Linux user for more than 15 years. He has anextensive background in software development, includingtechnical support, quality assurance, and documentation.He is also the creator of LinuxCommand.org, a Linuxeducation and advocacy site featuring news, reviews,and extensive support for using the Linux command line.T H E L IN U X COMM A ND L INEYou’ve experienced the shiny, point-and-click surfaceof your Linux computer—now dive below and exploreits depths with the power of the command line.T H E F I N E ST I N G E E K E N T E RTA I N M E N T “ I L I E F L AT .”FSC LOGO 49.95 ( 52.95 CDN)SHELVE IN:COMPUTERS/LINUXThis book uses RepKover — a durable binding that won’t snap shut.SHOT TSw w w.nostarch.comTHE LINU XCO M M A N D L I N EACOMPLETE IN T RODUC T IONWILLIAM E. SHOT TS, JR.

PRAISE FOR THE LINUX COMMAND LINE“I can honestly say I have found THE beginner’s guide to Linux.”—LINUX JOURNAL“The most approachable tome on the subject.”—LINUX MAGAZINE“Anyone who reads this book and makes use of the examples provided willnot be able to avoid becoming a UNIX command line pro by the time they’vehit the end of the book.”—ITWORLD“The ideal guidebook into the world of the Linux (and UNIX and BSD)command line.”—DISTROWATCH.COM“If you would like to start using the command line, improve your existingskills, or simply want to discover tools that you were never even aware existed,this book has everything you need, and I wholly recommend it.”—PHIL BULL, AUTHOR OF THE OFFICIAL UBUNTU DOCUMENTATION“This is the best introduction to the command line I have read.”—BEGINLINUX.COM

THE LINUXCOMMAND LINEA CompleteIntroductionby William E. Shotts, Jr.San Francisco

THE LINUX COMMAND LINE. Copyright 2012 by William E. Shotts, Jr.All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronicor mechanical, including photocopying, recording, or by any information storage or retrieval system, without theprior written permission of the copyright owner and the publisher.Eighth printing17 16 158 9 10ISBN-10: 1-59327-389-4ISBN-13: 978-1-59327-389-7Publisher: William PollockProduction Editor: Serena YangCover Design: Octopod StudiosDevelopmental Editor: Keith FancherTechnical Reviewer: Therese BaoCopyeditor: Ward WebberCompositors: Serena Yang and Alison LawProofreader: Paula L. FlemingFor information on book distributors or translations, please contact No Starch Press, Inc. directly:No Starch Press, Inc.38 Ringold Street, San Francisco, CA 94103phone: 415.863.9900; info@nostarch.com; www.nostarch.comLibrary of Congress Cataloging-in-Publication DataShotts, William E.The Linux command line: a complete introduction / William E. Shotts, Jr.p. cm.Includes index.ISBN-13: 978-1-59327-389-7 (pbk.)ISBN-10: 1-59327-389-4 (pbk.)1. Linux. 2. Scripting Languages (Computer science) 3. Operating systems (Computers) I. Title.QA76.76.O63S5556 2011005.4'32--dc232011029198No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product andcompany names mentioned herein may be the trademarks of their respective owners. Rather than use a trademarksymbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and tothe benefit of the trademark owner, with no intention of infringement of the trademark.The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has beentaken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to anyperson or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by theinformation contained in it.

To Karen

BRIEF CONTENTSAcknowledgments.xxiiiIntroduction.xxvPART 1: LEARNING THE SHELLChapter 1: What Is the Shell?.3Chapter 2: Navigation.7Chapter 3: Exploring the System.13Chapter 4: Manipulating Files and Directories.25Chapter 5: Working with Commands.39Chapter 6: Redirection.49Chapter 7: Seeing the World as the Shell Sees It.59Chapter 8: Advanced Keyboard Tricks.69Chapter 9: Permissions.77Chapter 10: Processes.95PART 2: CONFIGURATION AND THE ENVIRONMENTChapter 11: The Environment.109Chapter 12: A Gentle Introduction to vi.121Chapter 13: Customizing the Prompt.139PART 3: COMMON TASKS AND ESSENTIAL TOOLSChapter 14: Package Management.149Chapter 15: Storage Media.159Chapter 16: Networking.175

Chapter 17: Searching for Files.187Chapter 18: Archiving and Backup.201Chapter 19: Regular Expressions.215Chapter 20: Text Processing.233Chapter 21: Formatting Output.267Chapter 22: Printing.285Chapter 23: Compiling Programs.297PART 4: WRITING SHELL SCRIPTSChapter 24: Writing Your First Script.309Chapter 25: Starting a Project.315Chapter 26: Top-Down Design.325Chapter 27: Flow Control: Branching with if.333Chapter 28: Reading Keyboard Input.347Chapter 29: Flow Control: Looping with while and until.357Chapter 30: Troubleshooting.363Chapter 31: Flow Control: Branching with case.375Chapter 32: Positional Parameters.381Chapter 33: Flow Control: Looping with for.393Chapter 34: Strings and Numbers.399Chapter 35: Arrays.415Chapter 36: Exotica.423Index.433viiiBrief Contents

CONTENTS IN DETAILACKNOW LEDGMEN TSINTR OD UCTIONxxiiixx vWhy Use the Command Line?.xxviWhat This Book Is About.xxviWho Should Read This Book.xxviiWhat’s in This Book.xxviiHow to Read This Book.xxviiiPrerequisites.xxviiiPA R T 1LEARNING THE SHELL1WHAT IS THE S HELL ?3Terminal Emulators.3Your First Keystrokes.4Command History.4Cursor Movement.4Try Some Simple Commands.5Ending a Terminal Session.62NAV I GATI ON7Understanding the Filesystem Tree.7The Current Working Directory.8Listing the Contents of a Directory.8Changing the Current Working Directory.9Absolute Pathnames.9Relative Pathnames.9Some Helpful Shortcuts.10

3EX PLO RI N G TH E S YST EM13More Fun with ls.13Options and Arguments.14A Longer Look at Long Format.15Determining a File’s Type with file.16Viewing File Contents with less.17A Guided Tour.19Symbolic Links.224MANIPULATING FILES AND DIRECTOR IE S25Wildcards.26mkdir—Create Directories.28cp—Copy Files and Directories.28mv—Move and Rename Files.30rm—Remove Files and Directories.31ln—Create Links.32Hard Links.32Symbolic Links.32Let’s Build a Playground.33Creating Directories.33Copying Files.33Moving and Renaming Files.34Creating Hard Links.35Creating Symbolic Links.36Removing Files and Directories.37Final Note.385WORK ING WITH COMMANDS39What Exactly Are Commands?.40Identifying Commands.40type—Display a Command’s Type.40which—Display an Executable’s Location.41Getting a Command’s Documentation.41help—Get Help for Shell Builtins.41- - help—Display Usage Information.42man—Display a Program’s Manual Page.42apropos—Display Appropriate Commands.43whatis—Display a Very Brief Description of a Command.44info—Display a Program’s Info Entry.44README and Other Program Documentation Files.45Creating Your Own Commands with alias.46Revisiting Old Friends.47xContents in Detail

6RED IR ECTION49Standard Input, Output, and Error.50Redirecting Standard Output.50Redirecting Standard Error.51Redirecting Standard Output and Standard Error to One File.52Disposing of Unwanted Output.52Redirecting Standard Input.53Pipelines.54Filters.55uniq—Report or Omit Repeated Lines.55wc—Print Line, Word, and Byte Counts.55grep—Print Lines Matching a Pattern.56head/tail—Print First/Last Part of Files.56tee—Read from Stdin and Output to Stdout and Files.57Final Note.587S E E IN G TH E WO R L D A S THE S HE LL S EE S I T59Expansion.59Pathname Expansion.60Tilde Expansion.61Arithmetic Expansion.62Brace Expansion.63Parameter Expansio

PRAISE FOR THE LINUX COMMAND LINE “I can honestly say I have found THE beginner’s guide to Linux.” —LINUX JOURNAL “The most approachable tome on the subject.” —LINUX MAGAZINE “Anyone who reads this book and makes use of the examples provided will not be able to avoid becoming a UNIX command line pro by the time they’ve

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Linux in a Nutshell Linux Network Administrator’s Guide Linux Pocket Guide Linux Security Cookbook Linux Server Hacks Linux Server Security Running Linux SELinux Understanding Linux Network Internals Linux Books Resource Center linux.oreilly.comis a complete catalog of O’Reilly’s books on Linux and Unix and related technologies .

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Other Linux resources from O’Reilly Related titles Building Embedded Linux Systems Linux Device Drivers Linux in a Nutshell Linux Pocket Guide Running Linux Understanding Linux Network Internals Understanding the Linux Kernel Linux Books Resource Center linu