Synopses & Reviews
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
- 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.
It's been said that "graphical user interfaces make easy tasks easy, while command-line interfaces make difficult tasks possible." The Linux Command Line shows readers how to control their computers and accomplish these difficult tasks using Bash, the Linux shell. Designed for command-line users of all levels, the book takes readers from the first keystrokes to the process of writing powerful programs in the command line's native language. Along the way, the author explores basic commands and file system navigation, OS configuration, classic command-line programs, shell programming, and much more, making The Linux Command Line an essential guide for all Linux users who wish to exploit the full power of their systems.
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.
Table of Contents
Dedication; 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; Learning the Shell; Chapter 1: What Is the Shell?; 1.1 Terminal Emulators; 1.2 Your First Keystrokes; 1.3 Try Some Simple Commands; 1.4 Ending a Terminal Session; Chapter 2: Navigation; 2.1 Understanding the Filesystem Tree; 2.2 The Current Working Directory; 2.3 Listing the Contents of a Directory; 2.4 Changing the Current Working Directory; Chapter 3: Exploring the System; 3.1 More Fun with ls; 3.2 Determining a File's Type with file; 3.3 Viewing File Contents with less; 3.4 A Guided Tour; 3.5 Symbolic Links; Chapter 4: Manipulating Files and Directories; 4.1 Wildcards; 4.2 mkdir--Create Directories; 4.3 cp--Copy Files and Directories; 4.4 mv--Move and Rename Files; 4.5 rm--Remove Files and Directories; 4.6 ln--Create Links; 4.7 Let's Build a Playground; 4.8 Final Note; Chapter 5: Working with Commands; 5.1 What Exactly Are Commands?; 5.2 Identifying Commands; 5.3 Getting a Command's Documentation; 5.4 Creating Your Own Commands with alias; 5.5 Revisiting Old Friends; Chapter 6: Redirection; 6.1 Standard Input, Output, and Error; 6.2 Pipelines; 6.3 Final Note; Chapter 7: Seeing the World as the Shell Sees It; 7.1 Expansion; 7.2 Quoting; 7.3 Final Note; Chapter 8: Advanced Keyboard Tricks; 8.1 Command Line Editing; 8.2 Completion; 8.3 Using History; 8.4 Final Note; Chapter 9: Permissions; 9.1 Owners, Group Members, and Everybody Else; 9.2 Reading, Writing, and Executing; 9.3 Changing Identities; 9.4 Exercising Your Privileges; 9.5 Changing Your Password; Chapter 10: Processes; 10.1 How a Process Works; 10.2 Controlling Processes; 10.3 Signals; 10.4 More Process-Related Commands; Configuration and the Environment; Chapter 11: The Environment; 11.1 What Is Stored in the Environment?; 11.2 How Is the Environment Established?; 11.3 Modifying the Environment; 11.4 Final Note; Chapter 12: A Gentle Introduction to vi; 12.1 Why We Should Learn vi; 12.2 A Little Background; 12.3 Starting and Stopping vi; 12.4 Editing Modes; 12.5 Moving the Cursor Around; 12.6 Basic Editing; 12.7 Search and Replace; 12.8 Editing Multiple Files; 12.9 Saving Our Work; Chapter 13: Customizing the Prompt; 13.1 Anatomy of a Prompt; 13.2 Trying Some Alternative Prompt Designs; 13.3 Adding Color; 13.4 Moving the Cursor; 13.5 Saving the Prompt; 13.6 Final Note; Common Tasks and Essential Tools; Chapter 14: Package Management; 14.1 Packaging Systems; 14.2 How a Package System Works; 14.3 Common Package Management Tasks; 14.4 Final Note; Chapter 15: Storage Media; 15.1 Mounting and Unmounting Storage Devices; 15.2 Creating New Filesystems; 15.3 Testing and Repairing Filesystems; 15.4 Formatting Floppy Disks; 15.5 Moving Data Directly to and from Devices; 15.6 Creating CD-ROM Images; 15.7 Writing CD-ROM Images; 15.8 Extra Credit; Chapter 16: Networking; 16.1 Examining and Monitoring a Network; 16.2 Transporting Files over a Network; 16.3 Secure Communication with Remote Hosts; Chapter 17: Searching for Files; 17.1 locate--Find Files the Easy Way; 17.2 find--Find Files the Hard Way; Chapter 18: Archiving and Backup; 18.1 Compressing Files; 18.2 Archiving Files; 18.3 Synchronizing Files and Directories; Chapter 19: Regular Expressions; 19.1 What Are Regular Expressions?; 19.2 grep--Search Through Text; 19.3 Metacharacters and Literals; 19.4 The Any Character; 19.5 Anchors; 19.6 Bracket Expressions and Character Classes; 19.7 POSIX Basic vs. Extended Regular Expressions; 19.8 Alternation; 19.9 Quantifiers; 19.10 Putting Regular Expressions to Work; 19.11 Final Note; Chapter 20: Text Processing; 20.1 Applications of Text; 20.2 Revisiting Some Old Friends; 20.3 Slicing and Dicing; 20.4 Comparing Text; 20.5 Editing on the Fly; 20.6 Final Note; 20.7 Extra Credit; Chapter 21: Formatting Output; 21.1 Simple Formatting Tools; 21.2 Document Formatting Systems; 21.3 Final Note; Chapter 22: Printing; 22.1 A Brief History of Printing; 22.2 Printing with Linux; 22.3 Preparing Files for Printing; 22.4 Sending a Print Job to a Printer; 22.5 Monitoring and Controlling Print Jobs; Chapter 23: Compiling Programs; 23.1 What Is Compiling?; 23.2 Compiling a C Program; 23.3 Final Note; Writing Shell Scripts; Chapter 24: Writing Your First Script; 24.1 What Are Shell Scripts?; 24.2 How to Write a Shell Script; 24.3 More Formatting Tricks; 24.4 Final Note; Chapter 25: Starting a Project; 25.1 First Stage: Minimal Document; 25.2 Second Stage: Adding a Little Data; 25.3 Variables and Constants; 25.4 Here Documents; 25.5 Final Note; Chapter 26: Top-Down Design; 26.1 Shell Functions; 26.2 Local Variables; 26.3 Keep Scripts Running; 26.4 Final Note; Chapter 27: Flow Control: Branching with if; 27.1 Using if; 27.2 Exit Status; 27.3 Using test; 27.4 A More Modern Version of test; 27.5 (( ))--Designed for Integers; 27.6 Combining Expressions; 27.7 Control Operators: Another Way to Branch; 27.8 Final Note; Chapter 28: Reading Keyboard Input; 28.1 read--Read Values from Standard Input; 28.2 Validating Input; 28.3 Menus; 28.4 Final Note; 28.5 Extra Credit; Chapter 29: Flow Control: Looping with while and until; 29.1 Looping; 29.2 while; 29.3 Breaking out of a Loop; 29.4 until; 29.5 Reading Files with Loops; 29.6 Final Note; Chapter 30: Troubleshooting; 30.1 Syntactic Errors; 30.2 Logical Errors; 30.3 Testing; 30.4 Debugging; 30.5 Final Note; Chapter 31: Flow Control: Branching with case; 31.1 case; 31.2 Final Note; Chapter 32: Positional Parameters; 32.1 Accessing the Command Line; 32.2 Handling Positional Parameters En Masse; 32.3 A More Complete Application; 32.4 Final Note; Chapter 33: Flow Control: Looping with for; 33.1 for: Traditional Shell Form; 33.2 for: C Language Form; 33.3 Final Note; Chapter 34: Strings and Numbers; 34.1 Parameter Expansion; 34.2 Arithmetic Evaluation and Expansion; 34.3 bc--An Arbitrary-Precision Calculator Language; 34.4 Final Note; 34.5 Extra Credit; Chapter 35: Arrays; 35.1 What Are Arrays?; 35.2 Creating an Array; 35.3 Assigning Values to an Array; 35.4 Accessing Array Elements; 35.5 Array Operations; 35.6 Final Note; Chapter 36: Exotica; 36.1 Group Commands and Subshells; 36.2 Traps; 36.3 Asynchronous Execution; 36.4 Named Pipes; 36.5 Final Note; Colophon; Updates;