Practical Guide To Linux Commands, Editors & Shell...

Item Information
Item#: 9780134774602
Edition 04
Author Sobell & Helmke
Cover Paperback
On Hand 16
On Order 0
 


The Most Useful Tutorial and Reference, with Hundreds of High-Quality Examples for Every Popular Linux Distribution “First Sobell taught people how to use Linux . . . now he teaches you the power of Linux. A must-have book for anyone who wants to take Linux to the next level.” –Jon “maddog” Hall, Executive Director, Linux International Discover the Power of Linux—Covers macOS, too! Learn from hundreds of realistic, high-quality examples, and become a true command-line guru Covers MariaDB, DNF, and Python 3 300+ page reference section covers 102 utilities, including macOS commands For use with all popular versions of Linux, including Ubuntu,™ Fedora,™ openSUSE,™ Red Hat,® Debian, Mageia, Mint, Arch, CentOS, and macOS  Linux is today’s dominant Internet server platform. System administrators and Web developers need deep Linux fluency, including expert knowledge of shells and the command line. This is the only guide with everything you need to achieve that level of Linux mastery. Renowned Linux expert Mark Sobell has
ought together comprehensive, insightful guidance on the tools sysadmins, developers, and power users need most, and has created an outstanding day-to-day reference, updated with assistance from new coauthor Matthew Helmke.   This title is 100 percent distribution and release agnostic. Packed with hundreds of high-quality, realistic examples, it presents Linux from the ground up: the clearest explanations and most useful information about everything from filesystems to shells, editors to utilities, and programming tools to regular expressions.   Use a Mac? You’ll find coverage of the macOS command line, including macOS-only tools and utilities that other Linux/UNIX titles ignore.   A Practical Guide to Linux® Commands, Editors, and Shell Programming, Fourth Edition, is the only guide to deliver A MariaDB chapter to get you started with this ubiquitous relational database management system (RDBMS) A masterful introduction to Python for system administrators and power users In-depth coverage of the bash and tcsh shells, including a complete discussion of environment, inheritance, and process locality, plus coverage of basic and advanced shell programming Practical explanations of core utilities, from aspell to xargs, including printf and sshfs/curlftpfs, PLUS macOS–specific utilities from ditto to SetFile Expert guidance on automating remote backups using rsync Dozens of system security tips, including step-by-step walkthroughs of implementing secure communications using ssh and scp Tips and tricks for customizing the shell, including step values, sequence expressions, the eval builtin, and implicit command-line continuation High-productivity editing techniques using vim and emacs A comprehensive, 300-plus-page command reference section covering 102 utilities, including find, grep, sort, and tar Instructions for updating systems using apt-get and dnf And much more, including coverage of BitTorrent, gawk, sed, find, sort, bzip2, and regular expressions <
>

Table of Contents
Preface xxxv   Chapter 1: Welcome to Linux and macOS 1 The History of UNIX and GNU–Linux 3 What Is So Good About Linux? 6 Overview of Linux 11 Additional Features of Linux 16 Chapter Summary 18 Exercises 18   Part I: The Linux and macOS Operating Systems 21   Chapter 2: Getting Started 23 Conventions Used in This Book 24 Logging In from a Terminal (Emulator) 26 Working from the Command Line 28 su/sudo: Curbing Your Power (root Privileges) 32 Where to Find Documentation 33 More About Logging In and Passwords 42 Chapter Summary 46 Exercises 47 Advanced Exercises 48   Chapter 3: The Utilities 49 Special Characters 50 Basic Utilities 51 Working with Files 53 (Pipeline): Communicates Between Processes 60 Four More Utilities 61 Compressing and Archiving Files 64 Locating Utilities 69 Displaying User and System Information 71 Communicating with Other Users 75 Email 77 Chapter Summary 77 Exercises 80 Advanced Exercises 81   Chapter 4: The Filesystem 83 The Hierarchical Filesystem 84 Directory Files and Ordinary Files 85 Pathnames 90 Working with Directories 92 Access Permissions 100 ACLs: Access Control Lists 106 Links 112 Chapter Summary 122 Exercises 124 Advanced Exercises 126   Chapter 5: The Shell 127 Special Characters 128 Ordinary Files and Directory Files 129 The Command Line 130 Standard Input and Standard Output 137 Running a Command in the Background 150 Filename Generation/Pathname Expansion 152 Builtins 157 Chapter Summary 158 Exercises 159 Advanced Exercises 160   Part II: The Editors 163   Chapter 6: The vim Editor 165 History 166 Tutorial: Using vim to Create and Edit a File 167 Introduction to vim Features 175 Command Mode: Moving the Cursor 181 Input Mode 185 Command Mode: Deleting and Changing Text 186 Searching and Substituting 190 Miscellaneous Commands 197 Copying, Moving, and Deleting Text 197 Reading and Writing Files 200 Setting Parameters 201 Advanced Editing Techniques 206 Units of Measure 210 Chapter Summary 213 Exercises 218 Advanced Exercises 219   Chapter 7: The emacs Editor 221 History 222 Tutorial: Getting Started with emacs 224 Basic Editing Commands 231 Online Help 238 Advanced Editing 240 Major Modes: Language-Sensitive Editing 255 Customizing emacs 265 More Information 270 Chapter Summary 270 Exercises 279 Advanced Exercises 280   Part III: The Shells 283   Chapter 8: The Bourne Again Shell (bash) 285 Background 286 Startup Files 288 Commands That Are Symbols 291 Redirecting Standard Error 292 Writing and Executing a Simple Shell Script 294 Control Operators: Separate and Group Commands 299 Job Control 304 Manipulating the Directory Stack 307 Parameters and Variables 310 Special Characters 325 Locale 326 Time 330 Processes 333 History 336 Aliases 352 Functions 356 Controlling bash: Features and Options 359 Processing the Command Line 364 Chapter Summary 374 Exercises 376 Advanced Exercises 378   Chapter 9: The TC Shell (tcsh) 379 Shell Scripts 380 Entering and Leaving the TC Shell 381 Features Common to the Bourne Again and TC Shells 383 Redirecting Standard Error 389 Working with the Command Line 390 Variables 396 Control Structures 408 Builtins 418 Chapter Summary 422 Exercises 423 Advanced Exercises 425   Part IV: Programming Tools 427   Chapter 10: Programming the Bourne Again Shell (bash) 429 Control Structures 430 File Descriptors 464 Parameters 470 Variables 479 Builtin Commands 489 Expressions 505 Implicit Command-Line Continuation 512 Shell Programs 513 Chapter Summary 523 Exercises 525 Advanced Exercises 527   Chapter 11: The Perl Scripting Language 529 Introduction to Perl 530 Variables 538 Control Structures 545 Working with Files 554 Sort 558 Su
outines 559 Regular Expressions 562 CPAN Modules 568 Examples 570 Chapter Summary 574 Exercises 574 Advanced Exercises 575   Chapter 12: The Python Programming Language 577 Introduction 578 Scalar Variables, Lists, and Dictionaries 582 Control Structures 588 Reading from and Writing to Files 593 Regular Expressions 597 Defining a Function 598 Using Li
aries 599 Lambda Functions 603 List Comprehensions 604 Chapter Summary 605 Exercises 606 Advanced Exercises 606   Chapter 13: The MariaDB SQL Database Management System 609 History 610 Notes 611 Installing a MariaDB Server and Client 614 Client Options 615 Setting Up MariaDB 616 Creating a Database 618 Adding a User 619 Examples 620 Chapter Summary 633 Exercises 633   Chapter 14: The AWK Pattern Processing Language 635 Syntax 636 Arguments 636 Options 637 Notes 638 Language Basics 638 Examples 645 Advanced gawk Programming 662 Chapter Summary 667 Exercises 668 Advanced Exercises 668   Chapter 15: The sed Editor 669 Syntax 670 Arguments 670 Options 670 Editor Basics 671 Examples 674 Chapter Summary 685 Exercises 685   Part V: Secure Network Utilities 687   Chapter 16: The rsync Secure Copy Utility 689 Syntax 690 Arguments 690 Options 691 Examples 693 Chapter Summary 700 Exercises 701   Chapter 17: The OpenSSH Secure Communication Utilities 703 Introduction to OpenSSH 704 Running the ssh, scp, and sftp OpenSSH Clients 706 Setting Up an OpenSSH Server (sshd) 717 Troubleshooting 724 Tunneling/Port Forwarding 724 Chapter Summary 727 Exercises 728 Advanced Exercises 728   Part VI: Command Reference 729   Utilities That Display and Manipulate Files 731 Network Utilities 732 Utilities That Display and Alter Status 733 Utilities That Are Programming Tools 734 Miscellaneous Utilities 734 Standard Multiplicative Suffixes 735 Common Options 736 The sample Utility 736 sample: Brief description of what the utility does (macOS) 737 aspell: Checks a file for spelling errors 739 at: Executes commands at a specified time 743 busybox: Implements many standard utilities 747 bzip2: Compresses or decompresses files 750 cal: Displays a calendar 752 cat: Joins and displays files 753 cd: Changes to another working directory 755 chgrp: Changes the group associated with a file 757 chmod: Changes the access mode (permissions) of a file 759 chown: Changes the owner of a file and/or the group the file is associated with 764 cmp: Compares two files 766 comm: Compares sorted files 768 configure: Configures source code automatically 770 cp: Copies files 772 cpio: Creates an archive, restores files from an archive, or copies a directory hierarchy 776 crontab: Maintains crontab files 781 cut: Selects characters or fields from input lines 784 date: Displays or sets the system time and date 787 dd: Converts and copies a file 790 df: Displays disk space usage 793 diff: Displays the differences between two text files 795 diskutil: Checks, modifies, and repairs local volumes (macOS) 800 ditto: Copies files and creates and unpacks archives (macOS) 803 dmesg: Displays kernel messages 805 dscl: Displays and manages Directory Service information (macOS) 806 du: Displays information on disk usage by directory hierarchy and/or file 809 echo: Displays a message 812 expand/unexpand: Converts TABs to SPACEs and SPACEs to TABs 814 expr: Evaluates an expression 816 file: Displays the classification of a file 820 find: Finds files based on criteria 822 finger: Displays information about users 828 fmt: Formats text very simply 831 fsck: Checks and repairs a filesystem 833 ftp: Transfers files over a network 838 gawk: Searches for and processes patterns in a file 845 gcc: Compiles C and C++ programs 846 GetFileInfo: Displays file attributes (macOS) 851 grep: Searches for a pattern in files 853 gzip: Compresses or decompresses files 858 head: Displays the beginning of a file 861 join: Joins lines from two files based on a common field 863 kill: Terminates a process by PID 866 killall: Terminates a process by name 868 launchctl: Controls the launchd daemon (macOS) 870 less: Displays text files, one screen at a time 873 ln: Makes a link to a file 878 lpr: Sends files to printers 881 ls: Displays information about one or more files 884 make: Keeps a set of programs current 892 man: Displays documentation for utilities 898 mc: Manages files in a textual environment (aka Midnight Commander) 902 mkdir: Creates a directory 909 mkfs: Creates a filesystem on a device 911 mv: Renames or moves a file 914 nice: Changes the priority of a command 916 nl: Numbers lines from a file 918 nohup: Runs a command that keeps running after you log out 920 od: Dumps the contents of a file 921 open: Opens files, directories, and URLs (macOS) 926 otool: Displays object, li
ary, and executable files O 928 paste: Joins corresponding lines from files 930 pax: Creates an archive, restores files from an archive, or copies a directory hierarchy 932 plutil: Manipulates property list files (macOS) 938 pr: Paginates files for printing 940 printf: Formats string and numeric data 942 ps: Displays process status 946 renice: Changes the priority of a process 951 rm: Removes a file (deletes a link) 953 rmdir: Removes directories 955 rsync: Securely copies files and directory hierarchies over a network 956 scp: Securely copies one or more files to or from a remote system 957 screen: Manages several textual windows 958 sed: Edits a file noninteractively 964 SetFile: Sets file attributes (macOS) 965 sleep: Creates a process that sleeps for a specified interval 967 sort: Sorts and/or merges files 969 split: Divides a file into sections 978 ssh: Securely runs a program or opens a shell on a remote system 980 sshfs/curlftpfs: Mounts a directory on an OpenSSH or FTP server as a local directory 981 stat: Displays information about files 984 strings: Displays strings of printable characters from files 986 stty: Displays or sets terminal parameters 987 sysctl: Displays and alters kernel variables at runtime 991 tail: Displays the last part (tail) of a file 992 tar: Stores or retrieves files to/from an archive file 995 tee: Copies standard input to standard output and one or more files 1000 telnet: Connects to a remote computer over a network 1001 test: Evaluates an expression 1005 top: Dynamically displays process status 1008 touch: Creates a file or changes a file’s access and/or modification time 1012 tr: Replaces specified characters 1014 tty: Displays the terminal pathname 1017 tune2fs: Changes parameters on an ext2, ext3, or ext4 filesystem 1018 umask: Specifies the file-creation permissions mask 1021 uniq: Displays unique lines from a file 1023 w: Displays information about local system users 1025 wc: Displays the number of lines, words, and bytes in one or more files 1027 which: Shows where in PATH a utility is located 1028 who: Displays information about logged-in users 1030 xargs: Converts standard input to command lines 1032   Part VII: Appendixes 1035   Appendix A: Regular Expressions 1037 Characters 1038 Delimiters 1038 Simple Strings 1038 Special Characters 1038 Rules 1041 Bracketing Expressions 1042 The Replacement String 1042 Extended Regular Expressions 1043 Appendix Summary 1045   Appendix B: Help 1047 Solving a Problem 1048 Finding Linux and macOS Related Information 1049 Specifying a Terminal 1050   Appendix C: Keeping the System Up-to-Date 1053 Using dnf 1054 Using apt-get 1060 BitTorrent 1064   Appendix D: macOS Notes 1067 Open Directory 1068 Filesystems 1069 Extended Attributes 1070 Activating the Terminal META Key 1076 Startup Files 1076 Remote Logins 1076 Many Utilities Do Not Respect Apple Human Interface Guidelines 1076 Installing Xcode and MacPorts 1077 macOS Implementation of Linux Features 1078   Glossary 1081 File Tree Index 1135 Utility Index 1137 Main Index 1141

Review Quotes
Praise for Previous Editions of A Practical Guide to Linux® Commands, Editors, and Shell Programming   “This book is a very useful tool for anyone who wants to ‘look under the hood’ so to speak, and really start putting the power of Linux to work. What I find particularly frustrating about man pages is that they never include examples. Sobell, on the other hand, outlines very clearly what the command does and then gives several common, easy-to-understand examples that make it a
eeze to start shell programming on one’s own. As with Sobell’s other works, this is simple, straight-forward, and easy to read. It’s a great book and will stay on the shelf at easy arm’s reach for a long time.” –Ray Bartlett, Travel Writer   “Overall I found this book to be quite excellent, and it has earned a spot on the very front of my bookshelf. It covers the real ‘guts’ of Linux– the command line and its utilities–and does so very well. Its strongest points are the outstanding use of examples, and the Command Reference section. Highly recommended for Linux users of all skill levels. Well done to Mark Sobell and Prentice Hall for this outstanding book!” –Dan Clough, Electronics Engineer and Slackware Linux User   “Totally unlike most Linux books, this book avoids discussing everything via GUI and jumps right into making the power of the command line your friend.” –Bjorn Tipling, Software Engineer, ask.com   “This book is the best distro-agnostic, foundational Linux reference I’ve ever seen, out of dozens of Linux-related books I’ve read. Finding this book was a real stroke of luck. If you want to really understand how to get things done at the command line, where the power and flexibility of free UNIX-like OSes really live, this book is among the best tools you’ll find toward that end.” –Chad Perrin, Writer, TechRepublic   “I moved to Linux from Windows XP a couple of years ago, and after some distro hopping settled on Linux Mint. At age 69 I thought I might be biting off more than I could chew, but thanks to much reading and the help of a local LUG I am now quite at home with Linux at the GUI level. “Now I want to learn more about the CLI and a few months ago bought your book: A Practical Guide to Linux® Commands, Editors, and Shell Programming, Second Edition.   “For me, this book is proving to be the foundation upon which my understanding of the CLI is being built. As a comparative ‘newbie’ to the Linux world, I find your book a wonderful, easy-to-follow guide that I highly recommend to other Linux users.” –John Nawell, CQLUG (Central Queensland Linux User Group)   “I have the second edition of A Practical Guide to Linux® Commands, Editors, and Shell Programming and am a big fan. I used it while working as a Cisco support engineer. I plan to get the third edition as soon as it is released. We will be doing a ton of command-line work on literally 1000 boxes (IMS core nodes). I feel you have already given me a lot of tools with the second edition. I want to get your new book as soon as possible. The way you write works very well for my style of learning.” –Robert Lingenfelter, Support Engineer, VoIP/IMS   Praise for Other Books by Mark G. Sobell   “Since I’m in an educational environment, I found the content of Sobell’s book to be right on target and very helpful for anyone managing Linux in the enterprise. His style of writing is very clear. He builds up to the chapter exercises, which I find to be relevant to real-world scenarios a user or admin would encounter. An IT/IS student would find this book a valuable complement to their education. The vast amount of information is extremely well balanced and Sobell manages to present the content without complicated asides and meandering prose. This is a ‘must have’ for anyone managing Linux systems in a networked environment or anyone running a Linux server. I would also highly recommend it to an experienced computer user who is moving to the Linux platform.” –Mary Norbury, IT Director, Barbara Davis Center, University of Colorado at Denver, from a review posted on slashdot.org   “I had the chance to use your UNIX books when I when was in college years ago at Cal Poly, San Luis Obispo, CA. I have to say that your books are among the best! They’re quality books that teach the theoretical aspects and applications of the operating system.” –Benton Chan, IS Engineer   “The book has more than lived up to my expectations from the many reviews I read, even though it targets FC2. I have found something very rare with your book: It doesn’t read like the standard technical text, it reads more like a story. It’s a pleasure to read and hard to put down. Did I say that?! :-)” –David Hopkins, Business Process Architect   “Thanks for your work and for the book you wrote. There are really few books that can help people to become more efficient administrators of different workstations. We hope (in Russia) that you will continue
inging us a new level of understanding of Linux/UNIX systems.” –Anton Petukhov   “Mark Sobell has written a book as approachable as it is authoritative.” –Jeffrey Bianchine, Advocate, Author, Journalist   “Excellent reference book, well suited for the sysadmin of a Linux cluster, or the owner of a PC contemplating installing a recent stable Linux. Don’t be put off by the daunting heft of the book. Sobell has striven to be as inclusive as possible, in trying to anticipate your system administration needs.” –Wes Boudville, Inventor   “A Practical Guide to Red Hat® Linux® is a
illiant book. Thank you, Mark Sobell.” –C. Pozrikidis, University of California at San Diego   “This book presents the best overview of the Linux operating system that I have found. . . . [It] should be very helpful and understandable no matter what the reader’s background: traditional UNIX user, new Linux devotee, or even Windows user. Each topic is presented in a clear, complete fashion and very few assumptions are made about what the reader knows. . . . The book is extremely useful as a reference, as it contains a 70-page glossary of terms and is very well indexed. It is organized in such a way that the reader can focus on simple tasks without having to wade through more advanced topics until they are ready.” –Cam Marshall, Marshall Information Service LLC, Member of Front Range UNIX Users Group [FRUUG], Boulder, Colorado   “Conclusively, this is THE book to get if you are a new Linux user and you just got into RH/Fedora world. There’s no other book that discusses so many different topics and in such depth.” –Eugenia Loli-Queru, Editor in Chief, OSNews.com   “I currently own one of your books, A Practical Guide to Linux®. I believe this book is one of the most comprehensive and, as the title says, practical guides to Linux I have ever read. I consider myself a novice and I come back to this book over and over again.” –Albert J. Nguyen   “Thank you for writing a book to help me get away from Windows XP and to never touch Windows Vista. The book is great; I am learning a lot of new concepts and commands. Linux is definitely getting easier to use.” –James Moritz   “I am so impressed by how Mark Sobell can approach a complex topic in such an understandable manner. His command examples are especially useful in providing a novice (or even an advanced) administrator with a cookbook on how to accomplish real-world tasks on Linux. He is truly an inspired technical writer!” –George Vish II, Senior Education Consultant, Hewlett-Packard Company   “Overall, I think it’s a great, comprehensive Ubuntu book that’ll be a valuable resource for people of all technical levels.” –John Dong, Ubuntu Forum Council Member, Backports Team Leader   “The JumpStart sections really offer a quick way to get things up and running, allowing you to dig into the details of the book later.” –Scott Mann, Aztek Networks   “I would so love to be able to use this book to teach a class about not just Ubuntu or Linux but about computers in general. It is thorough and well written with good illustrations that explain important concepts for computer usage.” –Nathan Eckenrode, New York Local Community Team   “Ubuntu is gaining popularity at the rate alcohol did during Prohibition, and it’s great to see a well-known author write a book on the latest and greatest version. Not only does it contain Ubuntu-specific information, but it also touches on general computer-related topics, which will help the average computer user to better understand what’s going on in the background. Great work, Mark!” –Daniel R. Arfsten, Pro/ENGINEER Drafter/Designer   “I read a lot of Linux technical information every day, but I’m rarely impressed by tech books. I usually prefer online information sources instead. Mark Sobell’s books are a notable exception. They’re clearly written, technically accurate, comprehensive, and actually enjoyable to read.” –Matthew Miller, Senior Systems Analyst/Administrator, BU Linux Project, Boston University Office of Information Technology   “This is well-written, clear, comprehensive information for the Linux user of any type, whether trying Ubuntu on for the first time and wanting to know a little about it, or using the book as a very good reference when doing something more complicated like setting up a server. This book’s value goes well beyond its purchase price and it’ll make a great addition to the Linux section of your bookshelf.” –Linc Fessenden, Host of The LinuxLink TechShow, tllts.org   “The author has done a very good job at clarifying such a detail-oriented operating system. I have extensive Unix and Windows experience and this text does an excellent job at
idging the gaps between Linux, Windows, and Unix. I highly recommend this book to both ‘newbs’ and experienced users. Great job!” –Mark Polczynski, Information Technology Consultant   “Your text, A Practical Guide to Ubuntu Linux®, Third Edition, is a well constructed, informative, superbly written text. You deserve an award for outstanding talent; unfortunately my name is not Pulitzer.” –Harrison Donnelly, Physician   “When I first started working with Linux just a short ten years or so ago, it was a little more difficult than now to get going. . . . Now, someone new to the community has a vast array of resources available on the web, or if they are inclined to begin with Ubuntu, they can literally find almost every single thing they will need in the single volume of Mark Sobell’s A Practical Guide to Ubuntu Linux®.   “I’m sure this sounds a bit like hyperbole. Everything a person would need to know? Obviously not everything, but this book, weighing in at just under 1200 pages, covers so much so thoroughly that there won’t be much left out. From install to admin, networking, security, shell scripting, package management, and a host of other topics, it is all there. GUI and command-line tools are covered. There is not really any wasted space or fluff, just a huge amount of information. There are screen shots when appropriate but they do not take up an inordinate amount of space. This book is information-dense.” –JR Peck, Editor, GeekBook.org   “I have been wanting to make the jump to Linux but did not have the guts to do so–until I saw your familiarly titled A Practical Guide to Red Hat® Linux® at the bookstore. I picked up a copy and am eagerly looking forward to regaining my freedom.” –Carmine Stoffo, Machine and Process Designer to pharmaceutical industry   “I am currently reading A Practical Guide to Red Hat® Linux® and am finally understanding the true power of the command line. I am new to Linux and your book is a treasure.” –Juan Gonzalez   “Overall, A Practical Guide to Ubuntu Linux® by Mark G. Sobell provides all of the information a beginner to intermediate user of Linux would need to be productive. The inclusion of the Live DVD of the Gutsy Gibbon release of Ubuntu makes it easy for the user to test-drive Linux without affecting his installed OS. I have no doubts that you will consider this book money well spent.” –Ray Lodato, Slashdot contributor, www.slashdot.org