ENGLISH

The Linux Command Line

Book information

Publisher
No Starch
Year
2019
ISBN
978-1-59327-952-3
Language
english
Format
PDF
Filesize
2 MB (2243795 bytes)
Edition
2nd
Pages
471\471
Time added
2019-03-03 12:23:39

Description

Brief Contents......Page 3 Contents......Page 5 Intro......Page 17 Learning the Shell......Page 23 Terminal Emulators......Page 24 Cursor Movement......Page 25 Try Some Simple Commands......Page 26 Summing Up......Page 27 Understanding the File System Tree......Page 28 The Current Working Directory......Page 29 Relative Pathnames......Page 30 Some Helpful Shortcuts......Page 32 Summing Up......Page 33 More Fun with ls......Page 34 Options and Arguments......Page 35 A Longer Look at Long Format......Page 36 Determining a File’s Type with file......Page 37 Viewing File Contents with less......Page 38 Taking a Guided Tour......Page 39 Symbolic Links......Page 42 Summing Up......Page 43 4. Files & Directories......Page 44 Wildcards......Page 45 Useful Options and Examples......Page 47 mv—Move and Rename Files......Page 48 rm—Remove Files and Directories......Page 49 Useful Options and Examples......Page 50 Hard Links......Page 51 Copying Files......Page 52 Moving and Renaming Files......Page 53 Creating Hard Links......Page 54 Creating Symbolic Links......Page 55 Removing Files and Directories......Page 56 Summing Up......Page 58 5. Commands......Page 59 which—Display an Executable’s Location......Page 60 help—Get Help for Shell Builtins......Page 61 man—Display a Program’s Manual Page......Page 62 whatis—Display One-line Manual Page Descriptions......Page 64 info—Display a Program’s Info Entry......Page 65 Creating Our Own Commands with alias......Page 66 Summing Up......Page 68 6. Redirection......Page 69 Redirecting Standard Output......Page 70 Redirecting Standard Output and Standard Error to One File......Page 72 cat: Concatenate Files......Page 73 Filters......Page 75 uniq: Report or Omit Repeated Lines......Page 76 grep: Print Lines Matching a Pattern......Page 77 head/tail: Print First/Last Part of Files......Page 78 Summing Up......Page 79 Expansion......Page 81 Pathname Expansion......Page 82 Tilde Expansion......Page 83 Arithmetic Expansion......Page 84 Brace Expansion......Page 85 Parameter Expansion......Page 86 Quoting......Page 87 Double Quotes......Page 88 Single Quotes......Page 89 Backslash Escape Sequences......Page 90 Summing Up......Page 91 8. Advanced Keyboard Tricks......Page 92 Modifying Text......Page 93 Cutting and Pasting (Killing and Yanking) Text......Page 94 Completion......Page 95 Searching History......Page 96 History Expansion......Page 98 Summing Up......Page 99 9. Permissions......Page 100 Owners, Group Members, and Everybody Else......Page 101 Reading, Writing, and Executing......Page 102 chmod: Change File Mode......Page 104 Setting File Mode with the GUI......Page 107 umask: Set Default Permissions......Page 108 Some Special Permissions......Page 109 Changing Identities......Page 110 su: Run a Shell with Substitute User and Group IDs......Page 111 sudo: Execute a Command As Another User......Page 112 chown: Change File Owner and Group......Page 113 Exercising Our Privileges......Page 114 Changing Your Password......Page 116 Summing Up......Page 117 10. Processes......Page 118 Viewing Processes......Page 119 Viewing Processes Dynamically with top......Page 121 Controlling Processes......Page 123 Putting a Process in the Background......Page 124 Stopping (Pausing) a Process......Page 125 Sending Signals to Processes with kill......Page 126 Sending Signals to Multiple Processes with killall......Page 128 Shutting Down the System......Page 129 Summing Up......Page 130 Configuration & Environment......Page 131 11. Environment......Page 132 Examining the Environment......Page 133 Some Interesting Variables......Page 134 How Is the Environment Established?......Page 135 What’s in a Startup File?......Page 136 Text Editors......Page 138 Using a Text Editor......Page 139 Summing Up......Page 142 12. Gentle Intro to vi......Page 143 Starting and Stopping vi......Page 144 Editing Modes......Page 146 Moving the Cursor Around......Page 147 Appending Text......Page 148 Opening a Line......Page 149 Deleting Text......Page 150 Cutting, Copying, and Pasting Text......Page 151 Search-and-Replace......Page 152 Global Search-and-Replace......Page 153 Switching Between Files......Page 155 Opening Additional Files for Editing......Page 156 Inserting an Entire File into Another......Page 157 Saving Our Work......Page 158 Summing Up......Page 159 Anatomy of a Prompt......Page 160 Trying Some Alternative Prompt Designs......Page 162 Adding Color......Page 163 Moving the Cursor......Page 165 Summing Up......Page 166 Common Tasks & Essential Tools......Page 167 14. Package Management......Page 168 Package Files......Page 169 Dependencies......Page 170 Finding a Package in a Repository......Page 171 Installing a Package from a Package File......Page 172 Upgrading a Package from a Package File......Page 173 Displaying Information About an Installed Package......Page 174 Summing Up......Page 175 15. Storage Media......Page 177 Mounting and Unmounting Storage Devices......Page 178 Viewing a List of Mounted File Systems......Page 179 Determining Device Names......Page 182 Manipulating Partitions with fdisk......Page 185 Creating a New File System with mkfs......Page 187 Testing and Repairing File Systems......Page 188 Creating an Image Copy of a CD-ROM......Page 189 Writing CD-ROM Images......Page 190 Summing Up......Page 191 Extra Credit......Page 192 16. Networking......Page 193 ping......Page 194 traceroute......Page 195 netstat......Page 196 Transporting Files over a Network......Page 197 ftp......Page 198 lftp—a Better ftp......Page 199 ssh......Page 200 scp and sftp......Page 204 Summing Up......Page 205 17. Searching for Files......Page 206 locate—Find Files the Easy Way......Page 207 find—Find Files the Hard Way......Page 208 Tests......Page 209 Operators......Page 211 Predefined Actions......Page 213 Improving Efficiency......Page 215 xargs......Page 216 A Return to the Playground......Page 217 Summing Up......Page 219 18. Archiving and Backup......Page 220 gzip......Page 221 bzip2......Page 223 tar......Page 224 zip......Page 228 Synchronizing Files and Directories......Page 230 Using rsync over a Network......Page 233 Summing Up......Page 234 19. Regular Expressions......Page 235 grep......Page 236 Metacharacters and Literals......Page 237 Anchors......Page 238 Traditional Character Ranges......Page 240 POSIX Character Classes......Page 241 POSIX Basic vs. Extended Regular Expressions......Page 244 Alternation......Page 245 ? —Match an Element Zero or One Time......Page 246 * —Match an Element Zero or More Times......Page 247 { }—Match an Element a Specific Number of Times......Page 248 Validating a Phone List with grep......Page 249 Finding Ugly Filenames with find......Page 250 Searching for Text with less and vim......Page 251 Summing Up......Page 252 20. Text Processing......Page 254 Printer Output......Page 255 cat......Page 256 sort......Page 257 uniq......Page 263 cut—Remove Sections from Each Line of Files......Page 265 paste—Merge Lines of Files......Page 267 join—Join Lines of Two Files on a Common Field......Page 269 comm—Compare Two Sorted Files Line by Line......Page 271 diff—Compare Files Line by Line......Page 272 patch—Apply a diff to an Original......Page 274 tr—Transliterate or Delete Characters......Page 275 sed—Stream Editor for Filtering and Transforming Text......Page 277 aspell—Interactive Spellchecker......Page 284 Extra Credit......Page 287 21. Formatting Output......Page 288 nl—Number Lines......Page 289 fold—Wrap Each Line to a Specified Length......Page 291 fmt—A Simple Text Formatter......Page 292 pr—Format Text for Printing......Page 295 printf—Format and Print Data......Page 296 groff......Page 299 Summing Up......Page 304 22. Printing......Page 305 Character-Based Printers......Page 306 Graphical Printers......Page 307 pr—Convert Text Files for Printing......Page 308 Sending a Print Job to a Printer......Page 309 lp—Print Files (System V Style)......Page 310 Another Option: a2ps......Page 311 Monitoring and Controlling Print Jobs......Page 313 lpq—Display Printer Queue Status......Page 314 Summing Up......Page 315 23. Compiling Programs......Page 316 What Is Compiling?......Page 317 Compiling a C Program......Page 318 Obtaining the Source Code......Page 319 Examining the Source Tree......Page 321 Building the Program......Page 322 Installing the Program......Page 325 Summing Up......Page 326 Shell Scripts......Page 327 What Are Shell Scripts?......Page 328 Script File Format......Page 329 Script File Location......Page 330 Good Locations for Scripts......Page 331 Indentation and Line Continuation......Page 332 Summing Up......Page 333 25. Starting a Project......Page 334 First Stage: Minimal Document......Page 335 Second Stage: Adding a Little Data......Page 336 Variables and Constants......Page 337 Assigning Values to Variables and Constants......Page 339 Here Documents......Page 341 Summing Up......Page 343 26. Top-Down Design......Page 344 Shell Functions......Page 345 Local Variables......Page 348 Keep Scripts Running......Page 349 Summing Up......Page 352 27. Flow Control - if......Page 353 Exit Status......Page 354 File Expressions......Page 356 String Expressions......Page 358 Integer Expressions......Page 360 A More Modern Version of test......Page 361 (( ))—Designed for Integers......Page 362 Combining Expressions......Page 363 Control Operators: Another Way to Branch......Page 365 Summing Up......Page 366 28. Reading Keyboard Input......Page 367 read—Read Values from Standard Input......Page 368 Options......Page 370 IFS......Page 372 Validating Input......Page 374 Menus......Page 376 Extra Credit......Page 377 29. Flow Control - while/until......Page 378 while......Page 379 Breaking Out of a Loop......Page 381 until......Page 382 Reading Files with Loops......Page 383 Summing Up......Page 384 Syntactic Errors......Page 385 Missing Quotes......Page 386 Missing or Unexpected Tokens......Page 387 Unanticipated Expansions......Page 388 Defensive Programming......Page 389 Watch Out for Filenames......Page 390 Verifying Input......Page 391 Testing......Page 392 Finding the Problem Area......Page 393 Tracing......Page 394 Summing Up......Page 396 31. Flow Control - case......Page 397 The case Command......Page 398 Patterns......Page 399 Performing Multiple Actions......Page 401 Summing Up......Page 402 Accessing the Command Line......Page 403 Determining the Number of Arguments......Page 404 shift—Getting Access to Many Arguments......Page 405 Simple Applications......Page 406 Handling Positional Parameters en Masse......Page 407 A More Complete Application......Page 409 Summing Up......Page 412 for: Traditional Shell Form......Page 415 for: C Language Form......Page 418 Summing Up......Page 419 Parameter Expansion......Page 421 Expansions to Manage Empty Variables......Page 422 String Operations......Page 424 Case Conversion......Page 427 Number Bases......Page 429 Simple Arithmetic......Page 430 Assignment......Page 431 Bit Operations......Page 433 Logic......Page 434 Using bc......Page 436 An Example Script......Page 437 Extra Credit......Page 438 What Are Arrays?......Page 439 Assigning Values to an Array......Page 440 Accessing Array Elements......Page 441 Determining the Number of Array Elements......Page 443 Adding Elements to the End of an Array......Page 444 Deleting an Array......Page 445 Summing Up......Page 446 Group Commands and Subshells......Page 448 Process Substitution......Page 452 Traps......Page 454 Asynchronous Execution with wait......Page 457 Named Pipes......Page 458 Summing Up......Page 459 A......Page 460 C......Page 461 D......Page 462 F......Page 463 H......Page 464 L......Page 465 O......Page 466 P......Page 467 S......Page 468 T......Page 469 U......Page 470 Z......Page 471

Similar books