The linux command line - a complete introduction

482 2.5K 0
The linux command line -  a complete introduction

Đ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

Đây là bộ sách tiếng anh cho dân công nghệ thông tin chuyên về bảo mật,lập trình.Thích hợp cho những ai đam mê về công nghệ thông tin,tìm hiểu về bảo mật và lập trình.

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 THE LINUX COMMAND LINE THE LINUX COMMAND LINE A Complete Introduction by 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, 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. To Karen 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 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 [...]... 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 by default Press the down-arrow key, and the previous command disappears Cursor Movement Recall the previous command with the up-arrow... 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 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... “GNU /Linux instead, please perform a mental search and replace while reading this book I won’t mind Introduction xxix PART 1 LEARNING THE SHELL WHAT 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. .. 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 Part 3: Common Tasks and Essential Tools explores many of the ordinary tasks that are commonly performed from the command line Unixlike operating systems, such as... it was first developed a decade earlier), before the widespread adoption of the graphical user interface and, as a result, 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... [me@linuxbox ~]$ This is called a shell prompt, and it appears whenever the shell is ready to accept input While it may vary in appearance somewhat, depending on the distribution, it will usually include your username@machinename, followed by the current working directory (more about that in a little bit) and a dollar sign If the last character of the prompt is a hash mark (#) rather than a dollar sign,... know the only way to really get anything done on a computer is by typing on a keyboard Most computer users today are familiar with only the graphical user interface (GUI) and have been taught by vendors and pundits that the command line interface (CLI) is a terrifying thing of the past This is unfortunate, because a good command line interface is a marvelously expressive way of communicating with a computer... much the same way the written word is for human beings It’s been said that “graphical user interfaces make easy tasks easy, while command line interfaces make difficult tasks possible,” and this is still very true today Since Linux is modeled after the Unix family of operating systems, it shares the same rich heritage of command line tools as Unix Unix came into prominence during the early 1980s (although... on the Linux command line Unlike some books that concentrate on just a single program, such as the shell program, bash, this book will try to convey how to get along with the command line interface in a larger sense How does it all work? What can it do? What’s the best way to use it? xxvi Introduction This is not a book about Linux system administration While any serious discussion of the command line. .. not just a piece of software; it’s also a small part of the larger Unix culture, which has its own language and history I might throw in a rant or two, as well Introduction xxvii This book is divided into four parts, each covering some aspect 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 . INTRODUCTION THE LINUX COMMAND LINE THE LINUX COMMAND LINE WILLIAM E. SHOTTS, JR. THE LINUX COMMAND LINE THE LINUX COMMAND LINE SHOTTS THE LINUX COMMAND LINE THE. help—Display Usage Information 42 man—Display a Program’s Manual Page 42 apropos—Display Appropriate Commands 43 whatis—Display a Very Brief Description of a Command

Ngày đăng: 19/03/2014, 13:43

Từ khóa liên quan

Mục lục

  • Brief Contents

  • 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

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

Tài liệu liên quan