The Linux Command Line
Free

The Linux Command Line

By William E. Shotts, Jr.
Free
Book Description

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. - Publisher.

Print edition available from No Starch Press.

Table of Contents
  • 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
    • Acknowledgments
      • First Internet Edition
      • Second Internet Edition
      • Third Internet Edition
    • Your Feedback Is Needed!
    • What's New In The Third Internet Edition
    • Further Reading
    • Colophon
  • 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
      • Summing Up
      • Further Reading
    • 2 – Navigation
      • Understanding The File System Tree
      • The Current Working Directory
      • Listing The Contents Of A Directory
      • Changing The Current Working Directory
        • Absolute Pathnames
        • Relative Pathnames
        • Some Helpful Shortcuts
      • Summing Up
    • 3 – Exploring The System
      • More Fun With ls
        • Options And Arguments
        • A Longer Look At Long Format
      • Determining A File's Type With file
      • Viewing File Contents With less
      • A Guided Tour
      • Symbolic Links
      • Hard Links
      • Summing Up
      • Further Reading
    • 4 – Manipulating Files And Directories
      • Wildcards
      • mkdir – Create Directories
      • cp – Copy Files And Directories
        • Useful Options And Examples
      • mv – Move And Rename Files
        • Useful Options And Examples
      • rm – Remove Files And Directories
        • Useful Options And Examples
      • ln – Create Links
        • Hard Links
        • Symbolic Links
      • Let's Build A Playground
        • Creating Directories
        • Copying Files
        • Moving And Renaming Files
        • Creating Hard Links
        • Creating Symbolic Links
        • Removing Files And Directories
      • Summing Up
      • Further Reading
    • 5 – Working With Commands
      • What Exactly Are Commands?
      • Identifying Commands
        • type – Display A Command's Type
        • which – Display An Executable's Location
      • Getting A Command's Documentation
        • help – Get Help For Shell Builtins
        • --help – Display Usage Information
        • man – Display A Program's Manual Page
        • apropos – Display Appropriate Commands
        • whatis – Display A Very Brief Description Of A Command
        • info – Display A Program's Info Entry
        • README And Other Program Documentation Files
      • Creating Your Own Commands With alias
      • Summing Up
      • Further Reading
    • 6 – Redirection
      • Standard Input, Output, And Error
      • Redirecting Standard Output
      • Redirecting Standard Error
        • Redirecting Standard Output And Standard Error To One File
        • Disposing Of Unwanted Output
      • Redirecting Standard Input
        • cat – Concatenate Files
      • Pipelines
        • Filters
        • uniq - Report Or Omit Repeated Lines
        • wc – Print Line, Word, And Byte Counts
        • grep – Print Lines Matching A Pattern
        • head / tail – Print First / Last Part Of Files
        • tee – Read From Stdin And Output To Stdout And Files
      • Summing Up
    • 7 – Seeing The World As The Shell Sees It
      • Expansion
        • Pathname Expansion
        • Tilde Expansion
        • Arithmetic Expansion
        • Brace Expansion
        • Parameter Expansion
        • Command Substitution
      • Quoting
        • Double Quotes
        • Single Quotes
        • Escaping Characters
      • Summing Up
      • Further Reading
    • 8 – Advanced Keyboard Tricks
      • Command Line Editing
        • Cursor Movement
        • Modifying Text
        • Cutting And Pasting (Killing And Yanking) Text
      • Completion
      • Using History
        • Searching History
        • History Expansion
      • Summing Up
      • Further Reading
    • 9 – Permissions
      • Owners, Group Members, And Everybody Else
      • Reading, Writing, And Executing
        • chmod – Change File Mode
        • Setting File Mode With The GUI
        • umask – Set Default Permissions
      • Changing Identities
        • su – Run A Shell With Substitute User And Group IDs
        • sudo – Execute A Command As Another User
        • chown – Change File Owner And Group
        • chgrp – Change Group Ownership
      • Exercising Our Privileges
      • Changing Your Password
      • Summing Up
      • Further Reading
    • 10 – Processes
      • How A Process Works
      • Viewing Processes
        • Viewing Processes Dynamically With top
      • Controlling Processes
        • Interrupting A Process
        • Putting A Process In The Background
        • Returning A Process To The Foreground
        • Stopping (Pausing) A Process
      • Signals
        • Sending Signals To Processes With kill
        • Sending Signals To Multiple Processes With killall
      • Shutting Down The System
      • More Process Related Commands
      • Summing Up
  • Part 2 – Configuration And The Environment
    • 11 – The Environment
      • What Is Stored In The Environment?
        • Examining The Environment
        • Some Interesting Variables
      • How Is The Environment Established?
        • What's In A Startup File?
      • Modifying The Environment
        • Which Files Should We Modify?
        • Text Editors
        • Using A Text Editor
        • Activating Our Changes
      • Summing Up
      • Further Reading
    • 12 – A Gentle Introduction To vi
      • Why We Should Learn vi
      • A Little Background
      • Starting And Stopping vi
      • Editing Modes
        • Entering Insert Mode
        • Saving Our Work
      • Moving The Cursor Around
      • Basic Editing
        • Appending Text
        • Opening A Line
        • Deleting Text
        • Cutting, Copying, And Pasting Text
        • Joining Lines
      • Search-And-Replace
        • Searching Within A Line
        • Searching The Entire File
        • Global Search-And-Replace
      • Editing Multiple Files
        • Switching Between Files
        • Opening Additional Files For Editing
        • Copying Content From One File Into Another
        • Inserting An Entire File Into Another
      • Saving Our Work
      • Summing Up
      • Further Reading
    • 13 – Customizing The Prompt
      • Anatomy Of A Prompt
      • Trying Some Alternative Prompt Designs
      • Adding Color
      • Moving The Cursor
      • Saving The Prompt
      • Summing Up
      • Further Reading
  • Part 3 – Common Tasks And Essential Tools
    • 14 – Package Management
      • Packaging Systems
      • How A Package System Works
        • Package Files
        • Repositories
        • Dependencies
        • High And Low-level Package Tools
      • Common Package Management Tasks
        • Finding A Package In A Repository
        • Installing A Package From A Repository
        • Installing A Package From A Package File
        • Removing A Package
        • Updating Packages From A Repository
        • Upgrading A Package From A Package File
        • Listing Installed Packages
        • Determining If A Package Is Installed
        • Displaying Info About An Installed Package
        • Finding Which Package Installed A File
      • Summing Up
      • Further Reading
    • 15 – Storage Media
      • Mounting And Unmounting Storage Devices
        • Viewing A List Of Mounted File Systems
        • Determining Device Names
      • Creating New File Systems
        • Manipulating Partitions With fdisk
        • Creating A New File System With mkfs
      • Testing And Repairing File Systems
      • Formatting Floppy Disks
      • Moving Data Directly To/From Devices
      • Creating CD-ROM Images
        • Creating An Image Copy Of A CD-ROM
        • Creating An Image From A Collection Of Files
      • Writing CD-ROM Images
        • Mounting An ISO Image Directly
        • Blanking A Re-Writable CD-ROM
        • Writing An Image
      • Summing Up
      • Further Reading
      • Extra Credit
    • 16 – Networking
      • Examining And Monitoring A Network
        • ping
        • traceroute
        • ip
        • netstat
      • Transporting Files Over A Network
        • ftp
        • lftp – A Better ftp
        • wget
      • Secure Communication With Remote Hosts
        • ssh
        • scp And sftp
      • Summing Up
      • Further Reading
    • 17 – Searching For Files
      • locate – Find Files The Easy Way
      • find – Find Files The Hard Way
        • Tests
        • Operators
        • Predefined Actions
        • User-Defined Actions
        • Improving Efficiency
        • xargs
        • A Return To The Playground
        • Options
      • Summing Up
      • Further Reading
    • 18 – Archiving And Backup
      • Compressing Files
        • gzip
        • bzip2
      • Archiving Files
        • tar
        • zip
      • Synchronizing Files And Directories
        • Using rsync Over A Network
      • Summing Up
      • Further Reading
    • 19 – Regular Expressions
      • What Are Regular Expressions?
      • grep
      • Metacharacters And Literals
      • The Any Character
      • Anchors
      • Bracket Expressions And Character Classes
        • Negation
        • Traditional Character Ranges
        • POSIX Character Classes
      • POSIX Basic Vs. Extended Regular Expressions
      • Alternation
      • Quantifiers
        • ? - Match An Element Zero Or One Time
        • * - Match An Element Zero Or More Times
        • + - Match An Element One Or More Times
        • { } - Match An Element A Specific Number Of Times
      • Putting Regular Expressions To Work
        • Validating A Phone List With grep
        • Finding Ugly Filenames With find
        • Searching For Files With locate
        • Searching For Text With less And vim
      • Summing Up
      • Further Reading
    • 20 – Text Processing
      • Applications Of Text
        • Documents
        • Web Pages
        • Email
        • Printer Output
        • Program Source Code
      • Revisiting Some Old Friends
        • cat
        • sort
        • uniq
      • Slicing And Dicing
        • cut
        • paste
        • join
      • Comparing Text
        • comm
        • diff
        • patch
      • Editing On The Fly
        • tr
        • sed
        • aspell
      • Summing Up
      • Further Reading
      • Extra Credit
    • 21 – Formatting Output
      • Simple Formatting Tools
        • nl – Number Lines
        • fold – Wrap Each Line To A Specified Length
        • fmt – A Simple Text Formatter
        • pr – Format Text For Printing
        • printf – Format And Print Data
      • Document Formatting Systems
        • groff
      • Summing Up
      • Further Reading
    • 22 – Printing
      • A Brief History Of Printing
        • Printing In The Dim Times
        • Character-based Printers
        • Graphical Printers
      • Printing With Linux
      • Preparing Files For Printing
        • pr – Convert Text Files For Printing
      • Sending A Print Job To A Printer
        • lpr – Print Files (Berkeley Style)
        • lp – Print Files (System V Style)
        • Another Option: a2ps
      • Monitoring And Controlling Print Jobs
        • lpstat – Display Print System Status
        • lpq – Display Printer Queue Status
        • lprm / cancel – Cancel Print Jobs
      • Summing Up
      • Further Reading
    • 23 – Compiling Programs
      • What Is Compiling?
        • Are All Programs Compiled?
      • Compiling A C Program
        • Obtaining The Source Code
        • Examining The Source Tree
        • Building The Program
        • Installing The Program
      • Summing Up
      • Further Reading
  • Part 4 – Writing Shell Scripts
    • 24 – Writing Your First Script
      • What Are Shell Scripts?
      • How To Write A Shell Script
      • Script File Format
      • Executable Permissions
      • Script File Location
        • Good Locations For Scripts
      • More Formatting Tricks
        • Long Option Names
        • Indentation And line-continuation
      • Summing Up
      • Further Reading
    • 25 – Starting A Project
      • First Stage: Minimal Document
      • Second Stage: Adding A Little Data
      • Variables And Constants
        • Assigning Values To Variables And Constants
      • Here Documents
      • Summing Up
      • Further Reading
    • 26 – Top-Down Design
      • Shell Functions
      • Local Variables
      • Keep Scripts Running
      • Summing Up
      • Further Reading
    • 27 – Flow Control: Branching With if
      • if
      • Exit Status
      • test
        • File Expressions
        • String Expressions
        • Integer Expressions
      • A More Modern Version Of test
      • (( )) - Designed For Integers
      • Combining Expressions
      • Control Operators: Another Way To Branch
      • Summing Up
      • Further Reading
    • 28 – Reading Keyboard Input
      • read – Read Values From Standard Input
        • Options
        • IFS
      • Validating Input
      • Menus
      • Summing Up
        • Extra Credit
      • Further Reading
    • 29 – Flow Control: Looping With while / until
      • Looping
        • while
      • Breaking Out Of A Loop
        • until
      • Reading Files With Loops
      • Summing Up
      • Further Reading
    • 30 – Troubleshooting
      • Syntactic Errors
        • Missing Quotes
        • Missing Or Unexpected Tokens
        • Unanticipated Expansions
      • Logical Errors
        • Defensive Programming
        • Verifying Input
      • Testing
        • Test Cases
      • Debugging
        • Finding The Problem Area
        • Tracing
        • Examining Values During Execution
      • Summing Up
      • Further Reading
    • 31 – Flow Control: Branching With case
      • case
        • Patterns
        • Performing Multiple Actions
      • Summing Up
      • Further Reading
    • 32 – Positional Parameters
      • Accessing The Command Line
        • Determining The Number of Arguments
        • shift – Getting Access To Many Arguments
        • Simple Applications
        • Using Positional Parameters With Shell Functions
      • Handling Positional Parameters En Masse
      • A More Complete Application
      • Summing Up
      • Further Reading
    • 33 – Flow Control: Looping With for
      • for: Traditional Shell Form
      • for: C Language Form
      • Summing Up
      • Further Reading
    • 34 – Strings And Numbers
      • Parameter Expansion
        • Basic Parameters
        • Expansions To Manage Empty Variables
        • Expansions That Return Variable Names
        • String Operations
        • Case Conversion
      • Arithmetic Evaluation And Expansion
        • Number Bases
        • Unary Operators
        • Simple Arithmetic
        • Assignment
        • Bit Operations
        • Logic
      • bc – An Arbitrary Precision Calculator Language
        • Using bc
        • An Example Script
      • Summing Up
      • Extra Credit
      • Further Reading
    • 35 – Arrays
      • What Are Arrays?
      • Creating An Array
      • Assigning Values To An Array
      • Accessing Array Elements
      • Array Operations
        • Outputting The Entire Contents Of An Array
        • Determining The Number Of Array Elements
        • Finding The Subscripts Used By An Array
        • Adding Elements To The End Of An Array
        • Sorting An Array
        • Deleting An Array
      • Associative Arrays
      • Summing Up
      • Further Reading
    • 36 – Exotica
      • Group Commands And Subshells
        • Process Substitution
      • Traps
      • Asynchronous Execution
        • wait
      • Named Pipes
        • Setting Up A Named Pipe
        • Using Named Pipes
      • Summing Up
      • Further Reading
    • Index
    No review for this book yet, be the first to review.
      No comment for this book yet, be the first to comment
      Also Available On
      App store smallGoogle play small
      Categories
      Curated Lists
      • Pattern Recognition and Machine Learning (Information Science and Statistics)
        by Christopher M. Bishop
        Data mining
        by I. H. Witten
        The Elements of Statistical Learning: Data Mining, Inference, and Prediction
        by Various
        See more...
      • CK-12 Chemistry
        by Various
        Concept Development Studies in Chemistry
        by John Hutchinson
        An Introduction to Chemistry - Atoms First
        by Mark Bishop
        See more...
      • Microsoft Word - How to Use Advanced Algebra II.doc
        by Jonathan Emmons
        Advanced Algebra II: Activities and Homework
        by Kenny Felder
        de2de
        by
        See more...
      • The Sun Who Lost His Way
        by
        Tania is a Detective
        by Kanika G
        Firenze_s-Light
        by
        See more...
      • Java 3D Programming
        by Daniel Selman
        The Java EE 6 Tutorial
        by Oracle Corporation
        JavaKid811
        by
        See more...