ebook img

Practical Guide to Linux Commands Editors and Shell Programming PDF

02010·11.31 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Practical Guide to Linux Commands Editors and Shell Programming

A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU Table Of Contents 1. A Practical Guide to Linux Commands, Editors, and Shell Programming ................................. 8 2. Table of Contents ...................................................................................................................... 8 3. Copyright ................................................................................................................................. 15 4. Praise for Mark Sobell's Books ................................................................................................ 16 5. Preface .................................................................................................................................... 17 5.1 Command line interface (CLI) ........................................................................................... 17 5.2 Linux distributions ............................................................................................................. 18 5.3 Overlap .............................................................................................................................. 18 5.4 Audience ........................................................................................................................... 18 5.5 Benefits ............................................................................................................................. 18 5.6 Features Of This Book ....................................................................................................... 18 5.7 Contents ............................................................................................................................ 19 5.8 Supplements ..................................................................................................................... 23 5.9 Thanks ............................................................................................................................... 24 6. Chapter 1. Welcome to Linux.................................................................................................. 25 6.1 Free beer ........................................................................................................................... 26 6.2 The Gnu-Linux Connection ................................................................................................ 26 6.3 The Heritage of Linux: Unix ............................................................................................... 29 6.4 What is so good about linux? ............................................................................................ 30 6.5 Overview of Linux ............................................................................................................. 33 6.6 Additional Features of Linux ............................................................................................. 38 6.7 Chapter Summary ............................................................................................................. 40 6.8 Exercises ............................................................................................................................ 40 7. Part I: The Linux Operating System ......................................................................................... 41 7.1 Chapter 2. Getting Started ................................................................................................ 41 7.1.1 Conventions Used in This Book .................................................................................. 42 7.1.2 Logging In ................................................................................................................... 45 7.1.3 Working with the Shell ............................................................................................... 47 7.1.4 Curbing Your Power: Superuser Access ..................................................................... 50 7.1.5 Getting the Facts: Where to Find Documentation..................................................... 51 7.1.6 More About Logging In .............................................................................................. 59 7.1.7 Chapter Summary ...................................................................................................... 63 1 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 7.1.8 Exercises ..................................................................................................................... 63 7.1.9 Advanced Exercises .................................................................................................... 64 7.2 Chapter 3. Command Line Utilities ................................................................................... 64 7.2.1 Special Characters ...................................................................................................... 65 7.2.2 Basic Utilities .............................................................................................................. 67 7.2.3 Working with Files ..................................................................................................... 70 7.2.4 | (Pipe): Communicates Between Processes ............................................................. 80 7.2.5 Four More Utilities ..................................................................................................... 81 7.2.6 Compressing and Archiving Files ............................................................................... 85 7.2.7 Locating Commands ................................................................................................... 93 7.2.8 Obtaining User and System Information ................................................................... 96 7.2.9 Communicating with Other Users............................................................................ 102 7.2.10 Email....................................................................................................................... 103 7.2.11 Chapter Summary .................................................................................................. 104 7.2.12 Exercises ................................................................................................................. 107 7.2.13 Advanced Exercises ................................................................................................ 108 7.3 Chapter 4. The Linux Filesystem ..................................................................................... 109 7.3.1 The Hierarchical Filesystem ..................................................................................... 110 7.3.2 Directory and Ordinary Files .................................................................................... 111 7.3.3 Working with Directories ......................................................................................... 124 7.3.4 touch ........................................................................................................................ 125 7.3.5 Access peremissions ................................................................................................ 128 7.3.6 Links ......................................................................................................................... 134 7.3.7 Chapter summary .................................................................................................... 142 7.3.8 Exercises ................................................................................................................... 144 7.3.9 ADVANCED EXERCISES ............................................................................................. 146 7.4 Chapter 5. The Shell ........................................................................................................ 147 7.4.1 The Command Line .................................................................................................. 148 7.4.2 Standard Input and Standard Output ...................................................................... 156 7.4.3 Running a Program in the Background .................................................................... 172 7.4.4 Filename Generation/Pathname Expansion ............................................................ 175 7.4.5 Builtins ..................................................................................................................... 182 7.4.6 Chapter Summary .................................................................................................... 183 7.4.7 Exercises ................................................................................................................... 184 2 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 7.4.8 Advanced Exercises .................................................................................................. 186 8. Part II: The Editors ................................................................................................................. 187 8.1 Chapter 6. The vim Editor ............................................................................................... 187 8.1.1 History ...................................................................................................................... 188 8.1.2 Tutorial: Creating and Editing a File with vim .......................................................... 189 8.1.3 The compatible Parameter ...................................................................................... 198 8.1.4 Introduction to vim Features ................................................................................... 199 8.1.5 Command Mode: Moving the Cursor ...................................................................... 205 8.1.6 Input Mode .............................................................................................................. 210 8.1.7 Command Mode: Deleting and Changing Text ........................................................ 211 8.1.8 Searching and Substituting ...................................................................................... 215 8.1.9 Miscellaneous Commands ....................................................................................... 223 8.1.10 Yank, Put, and Delete Commands .......................................................................... 224 8.1.11 Reading and Writing Files ...................................................................................... 226 8.1.12 Setting Parameters ................................................................................................ 228 8.1.13 Advanced Editing Techniques ................................................................................ 234 8.1.14 Units of Measure ................................................................................................... 239 8.1.15 Chapter Summary .................................................................................................. 243 8.1.16 Exercises ................................................................................................................. 248 8.1.17 Advanced Exercises ................................................................................................ 249 8.2 Chapter 7. The emacs Editor ........................................................................................... 250 8.2.1 History ...................................................................................................................... 251 8.2.2 Tutorial: Getting Started with emacs ....................................................................... 253 8.2.3 Basic Editing Commands .......................................................................................... 260 8.2.4 Online Help .............................................................................................................. 266 8.2.5 Advanced Editing ..................................................................................................... 268 8.2.6 Language-Sensitive Editing ...................................................................................... 282 8.2.7 More Information .................................................................................................... 299 8.2.8 Chapter Summary .................................................................................................... 299 8.2.9 Exercises ................................................................................................................... 308 8.2.10 Advanced Exercises ................................................................................................ 310 9. Part III: THE SHELLS ............................................................................................................... 312 9.1 Chapter 8. The Bourne Again Shell ................................................................................. 312 9.1.1 Background .............................................................................................................. 313 3 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 9.1.2 Shell Basics ............................................................................................................... 314 9.1.3 Parameters and Variables ........................................................................................ 342 9.1.4 Processes.................................................................................................................. 364 9.1.5 History ...................................................................................................................... 368 9.1.6 Aliases ...................................................................................................................... 392 9.1.7 Functions .................................................................................................................. 399 9.1.8 Controlling bash Features and Options ................................................................... 403 9.1.9 Processing The Command Line ................................................................................ 408 9.1.10 Chapter Summary .................................................................................................. 422 9.1.11 Exercises ................................................................................................................. 424 9.1.12 Advanced Exercises ................................................................................................ 427 9.2 Chapter 9. The Tc Shell ................................................................................................... 429 9.2.1 Assignment statement ............................................................................................. 430 10. Part IV: Programming Tools ................................................................................................ 492 10.1 Chapter 10. Programming Tools ................................................................................... 493 10.1.1 Programming In C .................................................................................................. 493 10.1.2 Using Shared Libraries ........................................................................................... 504 10.1.3 make: Keeps a Set of Programs Current ................................................................ 507 10.1.4 Debugging C Programs ........................................................................................... 519 10.1.5 Threads .................................................................................................................. 534 10.1.6 System Calls ........................................................................................................... 534 10.1.7 Source Code Management .................................................................................... 536 10.1.8 Chapter Summary .................................................................................................. 552 10.1.9 Exercises ................................................................................................................. 553 10.1.10 Advanced Exercises .............................................................................................. 553 10.2 Chapter 11. Programming The Bourne Again Shell ...................................................... 555 10.2.1 Control Structures .................................................................................................. 558 10.2.2 file Descriptors ....................................................................................................... 612 10.2.3 Parameters And Variables ..................................................................................... 619 10.2.4 Builtin Commands .................................................................................................. 638 10.2.5 Expressions ............................................................................................................ 658 10.2.6 Shell Programs ....................................................................................................... 672 10.2.7 Chapter Summary .................................................................................................. 689 10.2.8 Exercises ................................................................................................................. 691 4 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 10.2.9 Advanced Exercises ................................................................................................ 693 10.3 Chapter 12. The gawk Pattern Processing Language .................................................... 695 10.3.1 Syntax ..................................................................................................................... 696 10.3.2 Arguments .............................................................................................................. 697 10.3.3 Options ................................................................................................................... 697 10.3.4 Notes ...................................................................................................................... 698 10.3.5 Language Basics ..................................................................................................... 698 10.3.6 Examples ................................................................................................................ 707 10.3.7 Error Messages ...................................................................................................... 750 10.3.8 Chapter Summary .................................................................................................. 752 10.3.9 Exercises ................................................................................................................. 752 10.3.10 Advanced Exercises .............................................................................................. 753 10.4 Chapter 13. The sed Editor ........................................................................................... 753 10.4.1 Syntax ..................................................................................................................... 754 10.4.2 Arguments .............................................................................................................. 754 10.4.3 Options ................................................................................................................... 754 10.4.4 Editor Basics ........................................................................................................... 755 10.4.5 Examples ................................................................................................................ 758 10.4.6 Chapter Summary .................................................................................................. 776 10.4.7 Exercises ................................................................................................................. 777 11. Part V: Command Reference............................................................................................... 778 11.1 Command Reference .................................................................................................... 778 11.1.1 Utilities That Display and Manipulate Files ............................................................ 778 11.1.2 Network Utilities .................................................................................................... 779 11.1.3 Utilities That Display and Alter Status ................................................................... 780 11.1.4 Utilities That Are Programming Tools .................................................................... 780 11.1.5 Miscellaneous Utilities ........................................................................................... 781 11.1.6 Standard Multiplicative Suffixes ............................................................................ 781 11.1.7 Common Options ................................................................................................... 782 11.1.8 The sample Utility .................................................................................................. 782 12. Part VI: Appendixes ........................................................................................................... 1084 12.1 Appendix A. Regular Expressions ................................................................................ 1084 12.1.1 Characters ............................................................................................................ 1085 12.1.2 Delimiters ............................................................................................................. 1085 5 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 12.1.3 Simple Strings ....................................................................................................... 1085 12.1.4 Special Characters ................................................................................................ 1086 12.1.5 Rules ..................................................................................................................... 1088 12.1.6 Bracketing Expressions ........................................................................................ 1090 12.1.7 The Replacement String ....................................................................................... 1091 12.1.8 Extended Regular Expressions ............................................................................. 1092 12.1.9 Appendix Summary .............................................................................................. 1093 12.2 Appendix B. Help ......................................................................................................... 1094 12.2.1 Solving A Problem ................................................................................................ 1095 12.2.2 Finding Linux-Related Information ...................................................................... 1098 12.2.3 Specifying a Terminal ........................................................................................... 1103 12.3 Appendix C. Keeping The System Up-To-Date ............................................................ 1106 12.3.1 yum: Updates And Installs Packages.................................................................... 1106 12.3.2 APT: An Alternative To yum ................................................................................. 1110 12.3.3 BitTorrent ............................................................................................................. 1119 13. Glossary ............................................................................................................................. 1123 14. Index ................................................................................................................................. 1218 14.1 index_SYMBOL ............................................................................................................ 1218 14.2 index_A ....................................................................................................................... 1223 14.3 index_B ....................................................................................................................... 1226 14.4 index_C ....................................................................................................................... 1233 14.5 index_D ....................................................................................................................... 1241 14.6 index_E ........................................................................................................................ 1247 14.7 index_F ........................................................................................................................ 1253 14.8 index_G ....................................................................................................................... 1261 14.9 index_H ....................................................................................................................... 1263 14.10 index_I ....................................................................................................................... 1265 14.11 index_J ...................................................................................................................... 1268 14.12 index_K ..................................................................................................................... 1268 14.13 index_L ...................................................................................................................... 1270 14.14 index_M .................................................................................................................... 1273 14.15 index_N ..................................................................................................................... 1277 14.16 index_O ..................................................................................................................... 1279 14.17 index_P...................................................................................................................... 1281 6 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 14.18 index_Q ..................................................................................................................... 1287 14.19 index_R ..................................................................................................................... 1287 14.20 index_S ...................................................................................................................... 1291 14.21 index_T ...................................................................................................................... 1304 14.22 index_U ..................................................................................................................... 1308 14.23 index_V ..................................................................................................................... 1314 14.24 index_W .................................................................................................................... 1321 14.25 index_X ..................................................................................................................... 1324 14.26 index_Y ...................................................................................................................... 1324 14.27 index_Z ...................................................................................................................... 1325 7 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU 1. A Practical Guide to Linux Commands, Editors, and Shell Programming By Mark G. Sobell ............................................... Publisher: Prentice Hall PTR Pub Date: July 01, 2005 ISBN: 0-13-147823-0 Pages: 1008 Table of Contents(See 2.) | Index(See 14.) The essential reference for core commands that Linux users need daily, along with superior tutorial on shell programming and much moreSystem administrators, software developers, quality assurance engineers and others working on a Linux system need to work from the command line in order to be effective. Linux is famous for its huge number of command line utility programs, and the programs themselves are famous for their large numbers of options, switches, and configuration files. But the truth is that users will only use a limited (but still significant) number of these utilities on a recurring basis, and then only with a subset of the most important and useful options, switches and configuration files. This book cuts through all the noise and shows them which utilities are most useful, and which options most important. And it contains examples, lot's and lot's of examples. This is not just a reprint of the man pages. And Linux is also famous for its "programmability." Utilities are designed, by default, to work wtih other utilities within shell programs as a way of automating system tasks. This book contains a superb introduction to Linux shell programming. And since shell programmers need to write their programs in text editors, this book covers the two most popular ones: vi and emacs. 2. Table of Contents A Practical Guide to Linux® Commands, Editors, and Shell Programming By Mark G. Sobell 8 A Practical Guide to Linux Commands, Editors, and Shell Programming @Team DDU ............................................... Publisher: Prentice Hall PTR Pub Date: July 01, 2005 ISBN: 0-13-147823-0 Pages: 1008 Table of Contents(See 2.) | Index(See 14.) Copyright(See 3.) Praise for Mark Sobell's Books(See 4.) Preface(See 5.) Command line interface (CLI)(See 5.1) Linux distributions(See 5.2) Overlap(See 5.3) Audience(See 5.4) Benefits(See 5.5) Features Of This Book(See 5.6) Contents(See 5.7) Supplements(See 5.8) Thanks(See 5.9) Chapter 1. Welcome to Linux(See 6.) Free beer(See 6.1) The Gnu–Linux Connection(See 6.2) The Heritage of Linux: Unix(See 6.3) What is so good about linux?(See 6.4) Overview of Linux(See 6.5) Additional Features of Linux(See 6.6) Chapter Summary(See 6.7) Exercises(See 6.8) 9

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.