A Practical Guide to Linux® Commands, Editors, and Shell Programming

Book description

Praise for Mark Sobell’s Books

“I keep searching for books that collect everything you want to know about a subject in one place, and keep getting disappointed. Usually the books leave out some important topic, while others go too deep in some areas and must skim lightly over the others. A Practical Guide to Red Hat® Linux® is one of those rare books that actually pulls it off. Mark G. Sobell has created a single reference for Red Hat Linux that cannot be beat! This marvelous text (with a 4-CD set of Linux Fedora Core 2 included) is well worth the price. This is as close to an ‘everything you ever needed to know’ book that I’ve seen. It’s just that good and rates 5 out of 5.”
—Ray Lodato, Slashdot contributor

“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 brilliant 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 is: 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

The Most Useful Linux Tutorial and Reference Ever, with Hundreds of High-Quality Examples Covering Every Linux Distribution!

To be truly productive with Linux, you need to thoroughly master the shells and the command line. Until now, you had to buy two books to gain that mastery: a tutorial on fundamental Linux concepts and techniques, plus a separate reference. Worse, most Linux references offer little more than prettied-up man pages. Now, there’s a far better solution. Renowned Linux expert Mark Sobell has brought together comprehensive, insightful guidance on the tools system administrators, developers, and power users need most, and an outstanding day-to-day reference, both in the same book.

This book is 100 percent distribution and release agnostic: You can use it on any Linux system, now and for years to come. What’s more, it’s packed with hundreds of high-quality examples: better examples than you’ll find in any other Linux guidebook. This is Linux from the ground up: the clearest explanations and most useful knowledge about everything from filesystems to shells, editors to utilities, and programming tools to regular expressions. And when you need instant answers, you’ll constantly turn to Sobell’s comprehensive command reference section—organized and tabbed for easy, fast access!

Don’t settle for yesterday’s Linux guidebook. Get the one book that meets today’s challenges—and tomorrow’s!

A Practical Guide to Linux® Commands, Editors, and Shell Programming is the most useful, most comprehensive Linux tutorial and reference you can find. It’s the only book to deliver

  • Better, more realistic examples covering tasks you’ll actually need to perform

  • Deeper insight, based on Sobell’s immense knowledge of every Linux nook and cranny

  • More practical explanations of more than eighty core utilities, from aspell to xargs

  • Techniques for implementing secure communications using ssh and scp—plus dozens of tips for making your system more secure

  • A superior introduction to the Linux programming environment, including make, gcc, gdb, CVS, and much more

  • Expert guidance on basic and advanced shell programming using bash and tcsh

  • Tips and tricks for customizing the shell and using it interactively from the command line

  • Thorough guides to vim and emacs, designed to help you get productive fast and maximize your editing efficiency

  • Dozens of exercises to help you practice and gain confidence

  • Instructions for using Apt, yum, and BitTorrent for keeping your system up to date automatically

  • And much more, including coverage of gawk, sed, find, sort, bzip2, and regular expressions



  • Table of contents

    1. Copyright
      1. Dedication
    2. Praise for Mark Sobell's Books
    3. Preface
      1. Command line interface (CLI)
      2. Linux distributions
      3. Overlap
      4. Audience
      5. Benefits
      6. Features Of This Book
      7. Contents
        1. Part I: The Linux Operating System
        2. Part II: The Editors
        3. Part III: The Shells
        4. Part IV: Programming Tools
        5. Part V: Command Reference
        6. Part VI: Appendixes
      8. Supplements
      9. Thanks
    4. 1. Welcome to Linux
      1. Free beer
      2. The Gnu–Linux Connection
        1. The History of Gnu–Linux
          1. Fade to 1983
          2. Next Scene, 1991
        2. The Code is Free
          1. MINIX
          2. GPL
        3. Have fun!
      3. The Heritage of Linux: Unix
      4. What is so good about linux?
        1. Applications
        2. Peripherals
        3. Software
        4. Platforms
        5. Emulators
        6. Why Linux Is Popular With Hardware Companies And Developers
          1. Proprietary operating systems
          2. Generic operating systems
        7. Linux Is Portable
        8. Standards
        9. The C Programming Language
      5. Overview of Linux
        1. Linux Has a Kernel Programming Interface
        2. Linux Can Support Many Users
        3. Linux Can Run Many Tasks
        4. Linux Provides a Secure Hierarchical Filesystem
          1. Standards
          2. Links
          3. Security
        5. The Shell: Command Interpreter And Programming Language
          1. Filename Generation
          2. Device-Independent Input And Output
            1. Redirection
          3. Shell Functions
          4. Job Control
        6. A Large Collection Of Useful Utilities
        7. Interprocess Communication
          1. Pipes and filters
        8. System Administration
      6. Additional Features of Linux
        1. Guis: Graphical User Interfaces
          1. Desktop manager
          2. Window manager
        2. (Inter)Networking Utilities
        3. Software Development
      7. Chapter Summary
      8. Exercises
    5. I. The Linux Operating System
      1. 2. Getting Started
        1. Conventions Used in This Book
          1. Text and examples
          2. Items you enter
          3. Utility names
          4. Filenames
          5. Character strings
          6. Keys and characters
          7. Prompts and RETURNs
          8. Definitions
          9. URLs (Web addresses)
          10. Tip, Caution, and Security boxes
        2. Logging In
          1. Logging In From a Terminal
          2. Logging In Remotely: Terminal Emulation, ssh, and telnet
        3. Working with the Shell
          1. Which Shell Are You Running?
          2. Correcting Mistakes
            1. Erasing a Character
            2. Deleting a Word
            3. Deleting a Line
            4. Aborting Execution
            5. Repeating/Editing Command Lines
        4. Curbing Your Power: Superuser Access
        5. Getting the Facts: Where to Find Documentation
          1. The ––help Option
          2. man: Displays the System Manual
            1. less (pager)
            2. Manual sections
          3. info: Displays Information About Utilities
          4. HOWTOs: Finding Out How Things Work
          5. Using the Internet to Get Help
            1. GNU
            2. The Linux Documentation Project
        6. More About Logging In
          1. What to Do If You Cannot Log In
          2. Logging Out
          3. Using Virtual Consoles
          4. Changing Your Password
        7. Chapter Summary
        8. Exercises
        9. Advanced Exercises
      2. 3. Command Line Utilities
        1. Special Characters
          1. Whitespace
          2. Backslash
          3. Single quotation marks
        2. Basic Utilities
          1. ls: Lists the Names of Files
          2. cat: Displays a Text File
          3. rm: Deletes a File
          4. less Is more: Displaying a Text File One Screen at a Time
            1. Pagers
          5. hostname: Displays the System Name
        3. Working with Files
          1. cp: Copies a File
          2. mv: Changes the Name of a File
          3. lpr: Prints a File
          4. grep: Finds a String
          5. head: Displays the Beginning of a File
          6. tail: Displays the End of a File
          7. sort: Displays a File in Order
          8. uniq: Removes Duplicate Lines from a File
          9. diff: Compares Two Files
          10. file: Tests the Contents of a File
        4. | (Pipe): Communicates Between Processes
        5. Four More Utilities
          1. echo: Displays Text
          2. date: Displays the Time and Date
          3. script: Records a Linux Session
          4. unix2dos: Converts Linux Files to Windows Format
            1. dos2unix
        6. Compressing and Archiving Files
          1. bzip2: Compresses a File
            1. .bz2 filename extension
          2. bunzip2 and bzcat: Decompress a File
            1. bzip2recover
          3. gzip: Compresses a File
            1. gunzip and zcat
            2. compress
          4. tar: Packs and Unpacks Files
        7. Locating Commands
          1. which and whereis: Locate a Utility
            1. which
            2. whereis
          2. apropos: Searches for a Keyword
            1. whatis
          3. slocate: Searches for a File
        8. Obtaining User and System Information
          1. who: Lists Users on the System
          2. finger: Lists Users on the System
            1. .plan and .project
          3. w: Lists Users on the System
        9. Communicating with Other Users
          1. write: Sends a Message
          2. mesg: Denies or Accepts Messages
        10. Email
          1. Network addresses
        11. Chapter Summary
        12. Exercises
        13. Advanced Exercises
      3. 4. The Linux Filesystem
        1. The Hierarchical Filesystem
          1. Family tree
          2. Directory tree
          3. Subdirectories
        2. Directory and Ordinary Files
          1. Filenames
            1. / or root
            2. Filename length
            3. Filename Extensions
            4. Invisible Filenames
          2. mkdir:Creates a Directory
          3. The working directory
            1. pwd
            2. Significance of the Working Directory
          4. Home Directory
            1. cd: Changes to Another Working Directory
            2. Startup files
          5. Absolute Pathnames
          6. Relative Pathnames
            1. The . and .. Directory entries
          7. Important Standard Directories and Files
        3. Working with Directories
          1. rmdir: Deletes a directory
          2. Pathnames
            1. touch
            2. ~ (Tilde) in pathnames
          3. mv, cp: Moves or Copies a File
          4. mv: Moves a Directory
        4. Access Permissions
          1. ls –l: Displays Permissions
          2. chmod: Changes Access Permissions
          3. Setuid and setgid permissions
          4. Directory access permissions
        5. Links
          1. SYMBOLIC LINKS
            1. Limitations of hard links
            2. ln: Creates a Symbolic Link
          2. rm: Removes a Link
        6. Chapter summary
        7. Exercises
        8. ADVANCED EXERCISES
      4. 5. The Shell
        1. The Command Line
          1. Syntax
            1. Command Name
              1. Usage message
            2. Arguments
              1. Options
                1. Combining options
                2. Option arguments
                3. Arguments that start with a hyphen
          2. Processing the Command Line
            1. Parsing the command line
            2. Absolute versus relative pathnames
          3. Executing the Command Line
            1. Process
            2. The shell does not process arguments
        2. Standard Input and Standard Output
          1. The Screen as a File
          2. The Keyboard and Screen as Standard Input and Standard Output
            1. cat
            2. CONTROL-D signals EOF
          3. Redirection
            1. Redirecting Standard Output
            2. Redirecting Standard Input
              1. Utilities that take input from a file or standard input
            3. noclobber: Avoids Overwriting Files
            4. Appending Standard Output to a File
            5. /dev/null: Making Data Disappear
          4. Pipes
            1. tr
            2. lpr
            3. Filters
            4. tee: Sends Output in Two Directions
        3. Running a Program in the Background
          1. Foreground
          2. Jobs
          3. Job number, PID number
          4. Moving a Job from the Foreground to the Background
            1. CONTROL-Z
          5. kill: Aborting A Background Job
            1. Determining a PID number with ps
        4. Filename Generation/Pathname Expansion
          1. Wildcards, globbing
          2. The ? Special Character
          3. The * Special Character
          4. The [ ] Special Characters
        5. Builtins
          1. Listing bash builtins
          2. Listing tcsh builtins
        6. Chapter Summary
          1. Utilities and Builtins Introduced in This Chapter
        7. Exercises
        8. Advanced Exercises
    6. II. The Editors
      1. 6. The vim Editor
        1. History
          1. vi clones
          2. What vim is not
          3. Reading this chapter
        2. Tutorial: Creating and Editing a File with vim
          1. vimtutor
          2. Specifying a terminal
          3. Starting vim
          4. Command and Input Modes
            1. Last Line mode
            2. vim is case sensitive
          5. Entering Text
            1. Input mode (i/a)
          6. Getting Help
            1. Correcting Text as You Insert It
            2. Moving the Cursor
            3. Deleting Text
              1. Delete character (x) Delete word (dw) Delete line (dd)
            4. Undoing Mistakes
              1. Undo (u)
              2. Redo (:redo)
            5. Entering Additional Text
              1. Insert (i) Append (a)
              2. Open (o and O)
            6. Correcting Text
          7. Ending the Editing Session
        3. The compatible Parameter
        4. Introduction to vim Features
          1. Online Help
          2. Modes of Operation
          3. The Display
            1. Status Line
            2. Redrawing the Screen
            3. Tilde (~) Symbol
          4. Correcting Text as You Insert It
          5. Work Buffer
          6. Line Length and File Size
          7. Windows
          8. File Locks
          9. Abnormal Termination of an Editing Session
          10. Recovering Text After a Crash
        5. Command Mode: Moving the Cursor
          1. Long lines
          2. Moving the Cursor by Characters
            1. l/h
          3. Moving the Cursor to a Specific Character
            1. f/F
          4. Moving the Cursor by Words
            1. w/W
            2. b/B
          5. Moving the Cursor by Lines
            1. j/k
          6. Moving the Cursor by Sentences and Paragraphs
            1. )/( }/{
          7. Moving the Cursor Within the Screen
            1. H/M/L
          8. Viewing Different Parts of the Work Buffer
            1. CONTROL-D CONTROL-U
            2. CONTROL-F CONTROL-B
            3. Line numbers (G)
        6. Input Mode
          1. Inserting Text
            1. Insert (i/I)
          2. Appending Text
            1. Append (a/A)
          3. Opening a Line for Text
            1. Open (o/O)
          4. Replacing Text
            1. Replace (r/R)
          5. Quoting Special Characters in Input Mode
            1. CONTROL-V
        7. Command Mode: Deleting and Changing Text
          1. Undoing Changes
            1. Undo (u/U)
          2. Deleting Characters
            1. Delete character (x/X)
          3. Deleting Text
            1. Delete (d/D)
          4. Changing Text
            1. Change (c/C)
          5. Replacing Text
            1. Substitute (s/S)
          6. Changing Case
        8. Searching and Substituting
          1. Searching for a Character
            1. Find (f/F)
            2. t/T
          2. Searching for a String
            1. Normal Versus Incremental Searches
            2. Special Characters in Search Strings
              1. ^ Beginning-of-Line Indicator
              2. $ End-of-Line Indicator
              3. . Any-Character Indicator
              4. \ > End-of-Word Indicator
              5. \ < Beginning-of-Word Indicator
              6. * Zero or More Occurrences
              7. [ ] Character-Class Definition
          3. Substituting One String for Another
            1. The Substitute Address
            2. Searching for and Replacing Strings
        9. Miscellaneous Commands
          1. Join
            1. Join (J)
          2. Status
            1. Status (CONTROL-G)
          3. . (Period)
            1. .
        10. Yank, Put, and Delete Commands
          1. The General-Purpose Buffer
            1. Copying Text to the Buffer
              1. Yank (y/Y)
            2. Copying Text From the Buffer
              1. Put (p/P)
            3. Deleting Text Copies It into the Buffer
        11. Reading and Writing Files
          1. Exit (ZZ)
          2. Reading Files
            1. Read (:r)
          3. Writing Files
            1. Write (:w)
            2. w!
          4. Identifying the Current File
        12. Setting Parameters
          1. Setting Parameters from Within vim
          2. Setting Parameters in a Startup File
            1. VIMINIT
          3. The .vimrc Startup File
          4. Parameters
        13. Advanced Editing Techniques
          1. Executing Shell Commands from Within vim
        14. Units of Measure
          1. Character
          2. Word
          3. Blank-Delimited Word
          4. Line
          5. Sentence
          6. Paragraph
          7. Window
          8. Repeat Factor
        15. Chapter Summary
        16. Exercises
        17. Advanced Exercises
      2. 7. The emacs Editor
        1. History
          1. Evolution
          2. emacs Versus vim
        2. Tutorial: Getting Started with emacs
          1. Starting emacs
          2. Stopping emacs
          3. Inserting Text
          4. Deleting Characters
          5. Moving the Cursor
            1. Moving the Cursor by Characters
              1. CONTROL-F
              2. CONTROL-B
            2. Moving the Cursor by Words
              1. META-f
              2. META-b
            3. Moving the Cursor by Lines
              1. CONTROL-A CONTROL-E CONTROL-P CONTROL-N
            4. Moving the Cursor by Sentences, Paragraphs, and Window Position
              1. META-a, META-e META-{, META-}
              2. META-r
          6. Editing at the Cursor Position
            1. Deleting text
          7. Saving and Retrieving the Buffer
            1. Backups
            2. Saving the buffer
            3. Visiting another file
        3. Basic Editing Commands
          1. Keys: Notation and Use
          2. Key Sequences and Commands
          3. META-x: Running a Command Without a Key Binding
            1. Smart completion
          4. Numeric Arguments
            1. CONTROL-U
          5. Point and the Cursor
          6. Scrolling Through a Buffer
            1. CONTROL-V META-v CONTROL-L
            2. META-<META->
          7. Erasing Text
            1. Delete versus kill
          8. Searching
            1. Incremental Searches
              1. CONTROL-S CONTROL-R
            2. Nonincremental Searches
              1. CONTROL-S RETURN CONTROL-R RETURN
            3. Regular Expression Searches
        4. Online Help
        5. Advanced Editing
          1. Undoing Changes
          2. Mark and Region
            1. Moving Mark and Establishing a Region
              1. CONTROL-@ CONTROL-SPACE CONTROL-X CONTROL-X
            2. Operating on a Region
            3. The Mark Ring
              1. CONTROL-U CONTROL-@
            4. Setting Mark Automatically
          3. Cut and Paste: Yanking Killed Text
          4. Inserting Special Characters
          5. Global Buffer Commands
            1. Line-Oriented Operations
            2. Unconditional and Interactive Replacement
          6. Files
            1. META-x pwd META-x cd
            2. Visiting Files
            3. Saving Files
          7. Buffers
          8. Windows
            1. Splitting a Window
            2. Manipulating Windows
              1. CONTROL-X o META-CONTROL-V
            3. Other-Window Display
              1. CONTROL-X 4b CONTROL-X 4f
            4. Adjusting and Deleting Windows
              1. CONTROL-X 0 CONTROL-X 1
              2. META-x shrink-window CONTROL-X ^ CONTROL-X } CONTROL-X {
          9. Foreground Shell Commands
          10. Background Shell Commands
            1. META-x compile
        6. Language-Sensitive Editing
          1. Selecting a Major Mode
            1. META-x modename
          2. Human-Language Modes
            1. Words
            2. Sentences
            3. Paragraphs
            4. Fill
            5. Case Conversion
            6. Text Mode
          3. C Mode
            1. Expressions
            2. Function Definitions
            3. Indention
          4. Customizing Indention
          5. Comments
          6. Special-Purpose Modes
            1. Shell Mode
        7. More Information
          1. Access to emacs
        8. Chapter Summary
        9. Exercises
        10. Advanced Exercises
    7. III. THE SHELLS
      1. 8. The Bourne Again Shell
        1. Background
          1. sh Shell
          2. Korn Shell
          3. POSIX standards
        2. Shell Basics
          1. Startup Files
            1. Login Shells
              1. /etc/profile
              2. .bash_profile .bash_login .profile
              3. .bash_logout
            2. Interactive Nonlogin Shells
              1. /etc/bashrc
              2. .bashrc
            3. Noninteractive Shells
              1. BASH_ENV
            4. Setting Up Startup Files
            5. . (Dot) OR source: Runs a Startup File in the Current Shell
          2. Commands That Are Symbols
          3. Redirecting Standard Error
            1. File descriptors
            2. Duplicating a file descriptor
            3. Sending errors to standard error
          4. Writing a Simple Shell Script
            1. chmod: Makes a File Executable
            2. #! Specifies a Shell
            3. # Begins A Comment
            4. Running A Shell Script
              1. fork and exec system calls
          5. Separating and Grouping Commands
            1. ; AND NEWLINE Separate Commands
              1. Whitespace
            2. \ Continues a Command
            3. | AND & Separate Commands and Do Something Else
          6. Job Control
            1. jobs: Lists Jobs
            2. fg: Brings a Job to the Foreground
            3. bg: Sends a Job to the Background
          7. Manipulating the Directory Stack
            1. dirs: Displays the Stack
            2. pushd: Pushes a Directory on the Stack
            3. popd: Pops a Directory Off the Stack
        3. Parameters and Variables
          1. Variables
          2. User-created variables
          3. Keyword variables
          4. Positional parameters Special parameters
          5. User-Created Variables
            1. Quoting the $
            2. SPACEs
            3. Pathname expansion in assignments
            4. unset: Removes a Variable
          6. Variable Attributes
            1. readonly: Makes the Value of a Variable Permanent
            2. declare AND typeset: Assign Attributes to Variables
              1. Listing variable attributes
              2. Integer
          7. Keyword Variables
            1. HOME: Your Home Directory
              1. Tilde (~)
            2. PATH: Where the Shell Looks for Programs
              1. Working directory
            3. MAIL: Where Your Mail Is Kept
            4. PS1: User Prompt (Primary)
            5. PS2: User Prompt (Secondary)
            6. PS3: Menu Prompt
            7. PS4: Debugging Prompt
            8. IFS: Separates Input Fields (Word Splitting)
            9. CDPATH: Broadens the Scope of cd
            10. Keyword Variables: A Summary
          8. Special Characters
        4. Processes
          1. Process Structure
            1. fork system call
          2. Process Identification
            1. PID number
          3. Executing A Command
            1. fork and sleep
            2. Background process
            3. Builtins
            4. Variables
        5. History
          1. Variables That Control History
            1. Event number
          2. Reexecuting and Editing Commands
            1. fc: Displays, Edits, and Reexecutes Commands
              1. Viewing the History List
              2. Editing and Reexecuting Previous Commands
              3. Reexecuting Commands Without Calling the Editor
            2. Using an Exclamation Point (!) to Reference Events
              1. Event Designators
                1. !! reexecutes the previous event
                2. !n event number
                3. !string event text
          3. The Readline Library
            1. vi mode
            2. emacs mode
            3. vi Editing Mode
            4. emacs Editing Mode
            5. Readline Completion Commands
              1. Command Completion
              2. Pathname Completion
              3. Variable Completion
            6. .inputrc: Configuring Readline
              1. Variables
              2. Key Bindings
                1. bind
              3. Conditional Constructs
        6. Aliases
          1. Single Versus Double Quotation Marks in Aliases
          2. Examples of Aliases
        7. Functions
          1. Functions in startup files
        8. Controlling bash Features and Options
          1. Command Line Options
          2. Shell Features
            1. set ±o: Turns Shell Features On and Off
            2. shopt: Turns Shell Features On and Off
        9. Processing The Command Line
          1. History Expansion
          2. Alias Substitution
          3. Parsing and Scanning the Command Line
          4. Command Line Expansion
            1. Quote removal
            2. Order of Expansion
            3. Brace Expansion
            4. Tilde Expansion
            5. Parameter and Variable Expansion
            6. Arithmetic Expansion
              1. let builtin
            7. Command Substitution
            8. Word Splitting
            9. Pathname Expansion
              1. Quotation marks
              2. Levels of expansion
            10. Process Substitution
        10. Chapter Summary
          1. Running a shell script
          2. Job control
          3. Variables
          4. Process
          5. History
          6. Command line editors
          7. Aliases
          8. Functions
          9. Shell features
          10. Command line expansion
        11. Exercises
        12. Advanced Exercises
      2. 9. The Tc Shell
        1. Assignment statement
          1. Shell Scripts
          2. Entering and Leaving the TC Shell
            1. chsh
              1. Startup Files
                1. /etc/csh.cshrc and /etc/csh.login
                2. .tcshrc and .cshrc
                3. .history
                4. .login
                5. /etc/csh.logout and .logout
            2. Features Common to the Bourne Again and TC Shells
              1. Command Line Expansion (Substitution)
                1. History
                  1. history Builtin
                  2. History Expansion
                  3. Variables
                    1. history and savehist
                    2. histlit
                2. Aliases
                  1. Special Aliases
                  2. History Substitution In Aliases
              2. Job Control
              3. Filename Substitution
              4. Manipulating the Directory Stack
              5. Command Substitution
            3. Redirecting Standard Error
            4. Working with the Command Line
              1. Word Completion
                1. Filename Completion
                2. Tilde Completion
                3. Command and Variable Completion
              2. Editing the Command Line
                1. bindkey
                2. Correcting Spelling
                  1. before you press return
                  2. After You Press Return
              3. Variables
                1. Variable name
                2. Variable Substitution
                3. String Variables
                4. Arrays of String Variables
                5. Numeric Variables
                  1. Expressions
                    1. Postincrement and postdecrement operators
                  2. Arrays of Numeric Variables
                6. Braces
                7. Special Variable Forms
                  1. Reading User Input
                8. Shell Variables
                  1. Shell Variables That Take On Values
                  2. Shell Variables That Act as Switches
              4. Control Structures
                1. if
                2. goto
                3. Interrupt Handling
                4. if...then...else
                5. foreach
                6. while
                7. break and continue
                8. switch
              5. Builtins
              6. Chapter Summary
                1. setenv
                  1. Aliases
                  2. Globbing
                2. Exercises
                3. Advanced Exercises
    8. IV. Programming Tools
      1. 10. Programming Tools
        1. Programming In C
          1. Checking Your Compiler
          2. A C Programming Example
            1. Symbolic constants
            2. Macros
            3. Headers (include files)
            4. Function prototype
            5. Functions
          3. Compiling and Linking a C Program
            1. ELF format
        2. Using Shared Libraries
          1. Archived libraries
          2. ldd
          3. Fixing Broken Binaries
            1. Wrappers
          4. Creating Shared Libraries
            1. C+ +
        3. make: Keeps a Set of Programs Current
          1. Dependency lines: target files and prerequisite files
          2. Implied Dependencies
            1. touch
            2. –n
            3. –t
            4. –j
        4. Debugging C Programs
          1. gcc: Compiler Warning Options
          2. Symbolic Debugger
            1. Core dumps
            2. gdb: Symbolic Debugger
            3. Graphical Symbolic Debuggers
        5. Threads
        6. System Calls
          1. strace: Traces System Calls
          2. Controlling Processes
          3. Accessing The Filesystem
        7. Source Code Management
          1. CVS: Concurrent Versions System
            1. Built-In CVS Help
            2. How CVS Stores Revision Files
            3. Basic Cvs Commands
              1. Checking Out Files from the Source Repository
              2. Making Your Changes Available to Others
              3. Updating Your Copies with Changes by Others
              4. Adding New Files to the Repository
              5. Removing Files from the Repository
            4. Other CVS Commands
              1. Tagging a Release
              2. Extracting a Release
              3. Removing Working Files
            5. Adding a Module to the Repository
            6. CVS Administration
            7. Using TkCVS
        8. Chapter Summary
          1. gcc
          2. gdb
          3. make
        9. Exercises
        10. Advanced Exercises
      2. 11. Programming The Bourne Again Shell
        1. Control Structures
          1. if...then
            1. test builtin
            2. Builtins
            3. Checking arguments
            4. [] is a synonym for test
            5. Usage message
          2. if...then...else
          3. if...then...elif
            1. Debugging Shell Scripts
          4. for...in
          5. for
          6. while
            1. test builtin
          7. until
            1. trap builtin
          8. break AND continue
          9. case
          10. select
            1. PS3
          11. Here Document
        2. File Descriptors
          1. Opening a file descriptor
          2. Duplicating a file descriptor
        3. Parameters And Variables
          1. Array Variables
          2. Locality of Variables
            1. Functions
              1. Function local variables
          3. Special Parameters
            1. $$: PID Number
              1. $!
            2. $?: Exit Status
          4. Positional Parameters
            1. $#: Number of Command Line Arguments
            2. $0: Name of the Calling Program
            3. $1 – $n: Command Line Arguments
              1. $*
              2. "$*" versus "$@"
            4. shift: Promotes Command Line Arguments
            5. set: Initializes Command Line Arguments
          5. Expanding Null and Unset Variables
            1. : – Uses a Default Value
            2. := Assigns a Default Value
              1. : builtin
            3. :? Displays An Error Message
        4. Builtin Commands
          1. type: Displays Information About a Command
          2. read: Accepts User Input
            1. REPLY
          3. exec: Executes a Command
            1. exec versus . (dot)
            2. exec runs a command
            3. exec does not return control
            4. exec redirects input and output
            5. /dev/tty
          4. trap: Catches a Signal
            1. : (null) builtin
          5. kill: Aborts a Process
          6. getopts: Parses Options
          7. A Partial List of Builtins
        5. Expressions
          1. Arithmetic Evaluation
            1. Logical expressions
          2. Logical Evaluation (Conditional Expressions)
            1. String comparisons
          3. String Pattern Matching
          4. Operators
            1. Pipe
            2. Increment and decrement operators
            3. Remainder
            4. Boolean
            5. Ternary
            6. Assignment
            7. Other bases
        6. Shell Programs
          1. A Recursive Shell Script
            1. makepath
          2. The quiz Shell Script
            1. quiz
        7. Chapter Summary
          1. Control structures
          2. File descriptors
          3. Variables
          4. Builtins
          5. Utilities in scripts
          6. Expressions
        8. Exercises
        9. Advanced Exercises
      3. 12. The gawk Pattern Processing Language
        1. Syntax
        2. Arguments
        3. Options
          1. – –field-separator fs
          2. – –file program-file
          3. – –assign var =value
        4. Notes
        5. Language Basics
          1. Patterns
            1. BEGIN and END
            2. , (comma)
          2. Actions
          3. Comments
          4. Variables
          5. Functions
          6. Arithmetic Operators
          7. Associative Arrays
          8. printf
          9. Control Structures
            1. if...else
            2. while
            3. for
            4. break
            5. continue
        6. Examples
          1. cars data file
          2. Missing pattern
          3. Missing action
          4. Single quotation marks
          5. Fields
          6. ~ (matches operator)
          7. Dollar signs
          8. Textual comparisons
          9. , (range operator)
          10. – –file option
          11. BEGIN
          12. length function
          13. NR (record number)
          14. END
          15. Stand-alone script
          16. OFS variable
          17. printf
          18. Redirecting output
          19. Associative arrays
        7. Error Messages
        8. Chapter Summary
        9. Exercises
        10. Advanced Exercises
      4. 13. The sed Editor
        1. Syntax
        2. Arguments
        3. Options
        4. Editor Basics
          1. Addresses
          2. Instructions
          3. Control Structures
            1. Branch instructions
          4. The Pattern Space and the Hold Space
        5. Examples
          1. program-file
          2. Append
          3. Insert
          4. Change
          5. Substitute
          6. Stand-alone script
          7. Hold space
        6. Chapter Summary
        7. Exercises
    9. V. Command Reference
      1. Command Reference
        1. Utilities That Display and Manipulate Files
        2. Network Utilities
        3. Utilities That Display and Alter Status
        4. Utilities That Are Programming Tools
        5. Miscellaneous Utilities
        6. Standard Multiplicative Suffixes
        7. Common Options
        8. The sample Utility
          1. sample: Very brief description of what the utility does
            1. Arguments
            2. Options
              1. ––delimiter=dchar
            3. Discussion
            4. Notes
            5. Examples
          2. aspell: Checks a file for spelling errors
            1. Action
            2. Arguments
            3. Options
            4. Discussion
            5. Notes
              1. Spelling from emacs
              2. Spelling from vim
            6. Examples
          3. at: Executes commands at a specified time
            1. Arguments
            2. Options
            3. Notes
              1. /etc/at.allow and /etc/at.deny
            4. Examples
          4. bzip2: Compresses or decompresses files
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
              1. bzcat file-list
              2. bzip2recover
            5. Examples
          5. cal: Displays a calendar
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          6. cat: Joins and displays files
            1. Arguments
            2. Options
              1. ––number-nonblank
              2. ––show-nonprinting
            3. Notes
            4. Examples
          7. cd: Changes to another working directory
            1. Arguments
            2. Notes
            3. Examples
          8. chgrp: Changes the group associated with a file
            1. Arguments
            2. Options
              1. ––no-dereference
              2. ––reference=rfile
            3. Notes
            4. Examples
          9. chmod: Changes the access mode (permissions) of a file
            1. Arguments
              1. Symbolic
              2. Absolute
            2. Options
              1. ––reference=rfile
            3. Notes
            4. Examples
          10. chown: Changes the owner of a file and/or the group the file is associated with
            1. Arguments
            2. Options
              1. ––no-dereference
              2. ––reference=rfile
            3. Notes
            4. Examples
          11. cmp: Compares two files
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          12. comm: Compares sorted files
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          13. configure: Configures source code automatically
            1. Options
              1. ––disable-feature
              2. ––enable-feature
              3. ––prefix=directory
            2. Discussion
            3. Notes
            4. Examples
          14. cp: Copies files
            1. Arguments
            2. Options
              1. ––no-dereference
              2. ––preserve=links
            3. Notes
            4. Examples
          15. cpio: Creates an archive or restores files from an archive
            1. Arguments
            2. Options
              1. Major Options
              2. Other Options
                1. ––reset–access–time
                2. ––make–directories
                3. ––pattern–file=filename
                4. ––preserve–modification–time
                5. ––no-absolute-filenames
            3. Discussion
            4. Examples
          16. crontab: Maintains crontab files
            1. Arguments
            2. Options
            3. Notes
              1. /etc/cron.allow /etc/cron.deny
            4. Examples
          17. cut: Selects characters or fields from input lines
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          18. date: Displays or sets the system time and date
            1. Arguments
              1. Setting the date
            2. Options
            3. Notes
            4. Examples
          19. dd: Converts and copies a file
            1. Arguments
            2. Notes
            3. Examples
              1. Wiping a file
              2. Copying a diskette
          20. df: Displays disk space usage
            1. Arguments
            2. Options
            3. Examples
          21. diff: Displays the differences between two files
            1. Arguments
            2. Options
            3. Notes
            4. Discussion
            5. Examples
              1. Context diff
          22. du: Displays information on disk usage by file
            1. Arguments
            2. Options
            3. Examples
          23. echo: Displays a message
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          24. expr: Evaluates an expression
            1. Arguments
            2. Notes
            3. Examples
          25. file: Displays the classification of a file
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          26. find: Finds files based on criteria
            1. Arguments
            2. Criteria
            3. Discussion
              1. Action criteria
            4. Notes
            5. Examples
          27. finger: Displays information about users
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
            5. Examples
          28. fmt: Formats text very simply
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          29. fsck: Checks and repairs a filesystem
            1. Arguments
            2. Options
              1. Global Options
              2. Filesystem Type-Specific Options
            3. Notes
              1. Interactive mode
              2. Order of checking
              3. fsck is a front end
              4. Boot time
              5. lost+found
            4. Messages
              1. Cleanup
          30. ftp: Transfers files over a network
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
              1. Anonymous FTP
              2. Passive versus active connections
              3. Automatic login
            5. Examples
              1. Connect and log in
              2. ls and cd
              3. get and put
              4. Timeout and open
              5. lcd (local cd)
              6. mget and prompt
          31. gcc: Compiles C and C++ programs
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          32. grep: Searches for a pattern in files
            1. Arguments
            2. Options
              1. Major Options
              2. Other Options
            3. Notes
              1. egrep and fgrep
            4. Examples
          33. gzip: Compresses or decompresses files
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
            5. Examples
          34. head: Displays the beginning of a file
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          35. kill: Terminates a process by PID
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          36. killall: Terminates a process by name
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          37. less: Displays text files, one screen at a time
            1. Arguments
            2. Options
            3. Notes
            4. Commands
            5. Examples
          38. ln: Makes a link to a file
            1. Arguments
            2. Options
            3. Notes
              1. Hard links
              2. Symbolic links
            4. Examples
          39. lpr: Sends files to printers
            1. Arguments
            2. Options
            3. Discussion
              1. lpq
              2. lprm
            4. Notes
              1. LPD and LPR
              2. CUPS
            5. Examples
          40. ls: Displays information about one or more files
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
            5. Examples
          41. make: Keeps a set of programs current
            1. Arguments
            2. Options
            3. Discussion
              1. Documentation
            4. Notes
            5. Examples
          42. man: Displays documentation for commands
            1. Arguments
            2. Options
            3. Discussion
              1. Pager
              2. MANPATH
            4. Notes
            5. Examples
          43. mkdir: Creates a directory
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          44. mkfs: Creates a filesystem on a device
            1. Arguments
            2. Options
              1. Global Options
              2. Filesystem Type-Specific Options
            3. Discussion
            4. Notes
              1. mkfs is a front end
            5. Examples
          45. Mtools: Uses DOS-style commands on files and directories
            1. Utilities
            2. Arguments
            3. Options
              1. mcopy
              2. mdir
              3. mformat
              4. mtype
            4. Discussion
            5. Notes
            6. Examples
          46. mv: Renames or moves a file
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          47. nice: Changes the priority of a command
            1. Arguments
            2. Options
              1. ––adjustment=value
            3. Notes
            4. Examples
          48. nohup: Runs a command that keeps running after you log out
            1. Arguments
            2. Notes
            3. Examples
          49. od: Dumps the contents of a file
            1. Arguments
            2. Options
              1. ––address–radix=base
            3. Notes
            4. Examples
          50. paste: Joins corresponding lines from files
            1. Arguments
            2. Options
              1. ––delimiter=dlist
            3. Notes
            4. Examples
          51. pr: Paginates files for printing
            1. Arguments
            2. Options
              1. ––show-control-chars
              2. ––number-lines=[c[num]]
              3. ––firstpage[:lastpage]
            3. Notes
            4. Examples
          52. ps: Displays process status
            1. Arguments
            2. Options
              1. ––User=username
            3. Discussion
            4. Notes
            5. Examples
              1. ps and kill
          53. rcp: Copies one or more files to or from a remote system
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          54. rlogin: Logs in on a remote system
            1. Arguments
            2. Options
            3. Notes
            4. Examples
              1. ~/.rhosts file
          55. rm: Removes a file (deletes a link)
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          56. rmdir: Removes a directory
            1. Arguments
            2. Options
              1. –– ignore-fail-on-non-empty
            3. Notes
            4. Examples
          57. rsh: Executes commands on a remote system
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          58. scp: Securely copies one or more files to or from a remote system
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          59. sleep: Creates a process that sleeps for a specified interval
            1. Arguments
            2. Examples
          60. sort: Sorts and/or merges files
            1. Arguments
            2. Options
              1. –– ignore-leading-blanks
              2. –– dictionary-order
              3. ––ignore-nonprinting
              4. ––key=start[,stop]
              5. ––output=filename
              6. ––field-separator=x
            3. Discussion
              1. Sort field
              2. Leading blanks
              3. Options
              4. Multiple sort fields
            4. Examples
          61. split: Divides a file into sections
            1. Arguments
            2. Options
              1. ––suffix-length=len
              2. ––numeric-suffixes
            3. Discussion
            4. Examples
          62. ssh: Securely executes commands on a remote system
            1. Arguments
            2. Options
            3. Notes
              1. OpenSSH
              2. Message on initial connection to a server
            4. Examples
          63. strings: Displays strings of printable characters
            1. Arguments
            2. Options
              1. ––print-file-name
            3. Discussion
            4. Examples
          64. stty: Displays or sets terminal parameters
            1. Options
              1. ––file=/dev/device
            2. Arguments
              1. Special Keys and Characteristics
              2. Modes of Data Transmission
              3. Treatment of Characters
              4. Job Control Parameters
            3. Notes
            4. Examples
          65. tail: Displays the last part (tail) of a file
            1. Arguments
            2. Options
              1. ––bytes=[+]n[u]
              2. ––sleep-interval=n
            3. Notes
            4. Examples
          66. tar: Stores or retrieves files to/from an archive file
            1. Arguments
            2. Options
            3. Modifiers
              1. ––blocking-factor=n
              2. ––ignore-failed-read
              3. ––one-file-system
              4. ––tape–length=n
              5. ––absolute-paths
              6. ––exclude-from=filename
            4. Notes
            5. Examples
          67. tee: Copies standard input to standard output and one or more files
            1. Arguments
            2. Options
              1. ––ignore-interrupts
            3. Examples
          68. telnet: Connects to a remote system over a network
            1. Arguments
            2. Options
            3. Discussion
              1. open remote-computer
            4. Notes
            5. Examples
          69. test: Evaluates an expression
            1. Arguments
            2. Notes
            3. Examples
          70. top: Dynamically displays process status
            1. Options
            2. Discussion
            3. Notes
            4. Examples
          71. touch: Changes a file's access and/or modification time
            1. Arguments
            2. Options
              1. ––date=datestring
              2. ––time=mtime or ––time=modify
            3. Examples
          72. tr: Replaces specified characters
            1. Arguments
              1. Ranges
              2. Character Classes
            2. Options
              1. ––squeeze-repeats
            3. Notes
            4. Examples
          73. tty: Displays the terminal pathname
            1. Arguments
            2. Options
            3. Notes
            4. Examples
          74. tune2fs: Changes parameters on an ext2 or ext3 filesystem
            1. Arguments
            2. Options
            3. Discussion
            4. Examples
          75. umask: Establishes the file-creation permissions mask
            1. Arguments
            2. Notes
            3. Examples
          76. uniq: Displays unique lines
            1. Arguments
            2. Options
            3. Examples
          77. w: Displays information about system users
            1. Arguments
            2. Options
            3. Discussion
            4. Examples
          78. wc: Displays the number of lines, words, and bytes
            1. Arguments
            2. Options
              1. ––max-line-length
            3. Notes
            4. Examples
          79. which: Shows where in PATH a command is located
            1. Arguments
            2. Options
              1. ––read-functions
            3. Notes
            4. Examples
          80. who: Displays information about logged-in users
            1. Arguments
            2. Options
            3. Discussion
            4. Notes
            5. Examples
          81. xargs: Converts standard input into command lines
            1. Arguments
            2. Options
              1. ––replace[=marker]
              2. ––max–lines[=num]
              3. ––max–args=num
              4. ––max–procs=num
              5. ––no–run–if–empty
            3. Discussion
            4. Notes
            5. Examples
    10. VI. Appendixes
      1. A. Regular Expressions
        1. Characters
        2. Delimiters
        3. Simple Strings
        4. Special Characters
          1. Periods
          2. Brackets
          3. Asterisks
          4. Carets and Dollar Signs
          5. Quoting Special Characters
        5. Rules
          1. Longest Match Possible
          2. Empty Regular Expressions
        6. Bracketing Expressions
        7. The Replacement String
          1. Ampersand
          2. Quoted Digit
        8. Extended Regular Expressions
        9. Appendix Summary
      2. B. Help
        1. Solving A Problem
        2. Finding Linux-Related Information
          1. Documentation
          2. Useful Linux Sites
          3. Linux Newsgroups
          4. Mailing Lists
          5. Words
          6. Software
          7. Office Suites and Word Processors
        3. Specifying a Terminal
          1. TERM
          2. LANG
      3. C. Keeping The System Up-To-Date
        1. yum: Updates And Installs Packages
          1. Configuring yum
          2. Using yum
        2. APT: An Alternative To yum
          1. Using Apt
            1. INSTALLING AND SETTING UP APT
              1. Update the local package list
              2. Check the dependency tree
              3. Update the system
            2. Adding And Removing Individual Packages
            3. apt.conf: Configuring Apt
              1. APT section
              2. RPM section
        3. BitTorrent
          1. Prerequisites
          2. How Bittorrent Works
          3. Using Bittorrent
    11. Glossary

    Product information

    • Title: A Practical Guide to Linux® Commands, Editors, and Shell Programming
    • Author(s): Mark G. Sobell
    • Release date: July 2005
    • Publisher(s): Pearson
    • ISBN: 0131478230