The Linux Command Line pot

482 3.5K 0
The Linux Command Line pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

You’ve experienced the shiny, point-and-click surface of your Linux computer—now dive below and explore its depths with the power of the command line. The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you’ll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more. In addition to that practical knowledge, author William Shotts reveals the philosophy behind these tools and the rich heritage that your desktop Linux machine has inherited from Unix supercomputers of yore. As you make your way through the book’s short, easily digestible chapters, you’ll learn how to: • Create and delete files, directories, and symlinks • Administer your system, including networking, package installation, and process management BANISH YOUR MOUSE BANISH YOUR MOUSE • Use standard input and output, redirection, and pipelines • 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 sed Once you overcome your initial “shell shock,” you’ll find that the command line is a natural and expressive way to communicate with your computer. Just don’t be surprised if your mouse starts to gather dust. ABOUT THE AUTHOR William E. Shotts, Jr., has been a software professional and avid Linux user for more than 15 years. He has an extensive background in software development, including technical support, quality assurance, and documentation. He is also the creator of LinuxCommand.org, a Linux education and advocacy site featuring news, reviews, and extensive support for using the Linux command line. SHELVE IN: COMPUTERS/LINUX $49.95 ($52.95 CDN) www.nostarch.com THE FINEST IN GEEK ENTERTAINMENT ™ FSC LOGO “I LIE FLAT.” This book uses RepKover— a durable binding that won’t snap shut. A COMPLETE INTRODUCTION THE LINUX COMMAND LINE THE LINUX COMMAND LINE WILLIAM E. SHOTTS, JR. THE LINUX COMMAND LINE THE LINUX COMMAND LINE SHOTTS www.it-ebooks.info www.it-ebooks.info THE LINUX COMMAND LINE www.it-ebooks.info www.it-ebooks.info THE LINUX COMMAND LINE A Complete Introduction by William E. Shotts, Jr. San Francisco www.it-ebooks.info 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, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. 16 15 14 13 12 1 2 3 4 5 6 7 8 9 ISBN-10: 1-59327-389-4 ISBN-13: 978-1-59327-389-7 Publisher: William Pollock Production Editor: Serena Yang Cover Design: Octopod Studios Developmental Editor: Keith Fancher Technical Reviewer: Therese Bao Copyeditor: Ward Webber Compositors: Serena Yang and Alison Law Proofreader: Paula L. Fleming For information on book distributors or translations, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 38 Ringold Street, San Francisco, CA 94103 phone: 415.863.9900; fax: 415.863.9950; info@nostarch.com; www.nostarch.com Library of Congress Cataloging-in-Publication Data Shotts, 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 2011 005.4'32 dc23 2011029198 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the 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 been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. www.it-ebooks.info To Karen www.it-ebooks.info www.it-ebooks.info BRIEF CONTENTS Acknowledgments xxiii Introduction xxv PART 1: LEARNING THE SHELL Chapter 1: What Is the Shell? 3 Chapter 2: Navigation 7 Chapter 3: Exploring the System 13 Chapter 4: Manipulating Files and Directories 25 Chapter 5: Working with Commands 39 Chapter 6: Redirection 49 Chapter 7: Seeing the World as the Shell Sees It 59 Chapter 8: Advanced Keyboard Tricks 69 Chapter 9: Permissions 77 Chapter 10: Processes 95 PART 2: CONFIGURATION AND THE ENVIRONMENT Chapter 11: The Environment 109 Chapter 12: A Gentle Introduction to vi 121 Chapter 13: Customizing the Prompt 139 PART 3: COMMON TASKS AND ESSENTIAL TOOLS Chapter 14: Package Management 149 Chapter 15: Storage Media 159 Chapter 16: Networking 175 www.it-ebooks.info Chapter 17: Searching for Files 187 Chapter 18: Archiving and Backup 201 Chapter 19: Regular Expressions 215 Chapter 20: Text Processing 233 Chapter 21: Formatting Output 267 Chapter 22: Printing 285 Chapter 23: Compiling Programs 297 PART 4: WRITING SHELL SCRIPTS Chapter 24: Writing Your First Script 309 Chapter 25: Starting a Project 315 Chapter 26: Top-Down Design 325 Chapter 27: Flow Control: Branching with if 333 Chapter 28: Reading Keyboard Input 347 Chapter 29: Flow Control: Looping with while and until 357 Chapter 30: Troubleshooting 363 Chapter 31: Flow Control: Branching with case 375 Chapter 32: Positional Parameters 381 Chapter 33: Flow Control: Looping with for 393 Chapter 34: Strings and Numbers 399 Chapter 35: Arrays 415 Chapter 36: Exotica 423 Index 433 viii Brief Contents www.it-ebooks.info [...]... of the command line experience: Part 1: Learning the Shell starts our exploration of the basic language of the command line, including such things as the structure of commands, filesystem navigation, command line editing, and finding help and documentation for commands Part 2: Configuration and the Environment covers editing configuration files that control the computer’s operation from the command line. .. Learning the command line is not a casual endeavor On the other hand, learning the Linux command line is extremely rewarding If you think you’re a “power user” now, just wait You don’t know what real power is—yet And, unlike many other computer skills, knowledge of the command line is long lasting The skills learned today will still be useful 10 years from now The command line has survived the test of time... gibberish at the prompt like so: [me@linuxbox ~]$ kaekfjaeifj Since this command makes no sense, the shell tells us so and gives us another chance: bash: kaekfjaeifj: command not found [me@linuxbox ~]$ Command History If we press the up-arrow key, we see that the previous command kaekfjaeifj reappears after the prompt This is called command history Most Linux distributions remember the last 500 commands... Stallman, the genius-philosopher who founded the Free Software movement, started the Free Software Foundation, formed the GNU Project, wrote the first version of the GNU C Compiler (GCC), created the GNU General Public License (the GPL), etc., etc He insists that you call it “GNU /Linux to properly reflect the contributions of the GNU Project While the GNU Project predates the Linux kernel and the project’s... all the security problems and want to give Linux a try That’s fine All are welcome here That being said, there is no shortcut to Linux enlightenment Learning the command line is challenging and takes real effort It’s not that it’s so hard, but rather it’s so vast The average Linux system has literally thousands of programs you can employ on the command line Consider yourself warned: Learning the command. .. IS THE SHELL? When we speak of the command line, we are really referring to the shell The shell is a program that takes keyboard commands and passes them to the operating system to carry out Almost all Linux distributions supply a shell program from the GNU Project called bash The name bash is an acronym for Bourne Again Shell, a reference to the fact that bash is an enhanced replacement for sh, the. .. placing them in the name is unfair to everyone else who made significant contributions Besides, I think Linux/ GNU” would be more technically accurate since the kernel boots first and everything else runs on top of it In popular usage, Linux refers to the kernel and all the other free and open source software found in the typical Linux distribution—that is, the entire Linux ecosystem, not just the GNU... developed an extensive command line interface instead In fact, one of the strongest reasons early adopters of Linux chose it over, say, Windows NT was the powerful command line interface, which made the “difficult tasks possible.” What This Book Is About This book is a broad overview of “living” on the Linux command line Unlike some books that concentrate on just a single program, such as the shell program,... solid foundation in the use of the command line, an essential tool for any serious system administration task This book is very Linux- centric Many other books try to broaden their appeal by including other platforms, such as generic Unix and Mac OS X In doing so, they “water down” their content to feature only general topics This book, on the other hand, covers only contemporary Linux distributions... correct to call the Linux operating system the “GNU /Linux operating system.” The problem with Linux is that there is no completely correct way to name it because it was written by many different people in a vast, distributed development effort Technically speaking, Linux is the name of the operating system’s kernel, nothing more The kernel is very important, of course, since it makes the operating . SHOTTS, JR. THE LINUX COMMAND LINE THE LINUX COMMAND LINE SHOTTS www.it-ebooks.info www.it-ebooks.info THE LINUX COMMAND LINE www.it-ebooks.info www.it-ebooks.info THE LINUX COMMAND LINE A Complete Introduction by. You’ve experienced the shiny, point-and-click surface of your Linux computer—now dive below and explore its depths with the power of the command line. The Linux Command Line takes you from. CDN) www.nostarch.com THE FINEST IN GEEK ENTERTAINMENT ™ FSC LOGO “I LIE FLAT.” This book uses RepKover— a durable binding that won’t snap shut. A COMPLETE INTRODUCTION THE LINUX COMMAND LINE THE LINUX COMMAND LINE WILLIAM

Ngày đăng: 31/03/2014, 17:20

Từ khóa liên quan

Mục lục

  • Acknowledgments

  • Introduction

    • Why Use the Command Line?

    • What This Book Is About

    • Who Should Read This Book

    • What’s in This Book

    • How to Read This Book

    • Prerequisites

    • Part 1: Learning the Shell

      • 1: What Is the Shell?

        • Terminal Emulators

        • Your First Keystrokes

          • Command History

          • Cursor Movement

          • Try Some Simple Commands

          • Ending a Terminal Session

          • 2: Navigation

            • Understanding the Filesystem Tree

            • The Current Working Directory

            • Listing the Contents of a Directory

            • Changing the Current Working Directory

              • Absolute Pathnames

              • Relative Pathnames

              • Some Helpful Shortcuts

              • 3: Exploring the System

                • More Fun with ls

                  • Options and Arguments

                  • A Longer Look at Long Format

Tài liệu cùng người dùng

Tài liệu liên quan