You are previewing Linux Phrasebook, Second Edition.
O'Reilly logo
Linux Phrasebook, Second Edition

Book Description

Get more done faster at the Linux command line! This best-selling Linux Phrasebook has been thoroughly updated in the second edition to reflect the newest distributions, incorporate feedback from hundreds of active Linux users, and cover today's newest tools and techniques -- including an entirely new chapter on text file manipulation.

Linux Phrasebook, Second Edition offers a concise, handy reference to the Linux commands that, like a language phrasebook, can be used on the spot on moment's notice.

Don't waste a minute on non-essentials: this straight-to-the-point reference delivers specific information and tested commands designed to work with any modern Linux distribution. Portable enough to take anywhere, it starts with a quick introduction to essential command line concepts, and then delivers all the modern Linux command examples, variations, and parameters you need to:

  • View, manipulate, archive, and compress files

  • Control file ownership and permissions

  • Find anything on your systems

  • Efficiently use the Linux shell

  • Monitor system resources

  • Install software

  • Test, fix, and work with networks

  • Linux Phrasebook, Second Edition is the perfect quick command line reference for millions of Linux users and administrators at all levels of experience: people who want to get reliable information they can use right now -- with no distractions and no diversions!

    Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Table of Contents
    5. About the Author
    6. Dedication
    7. Acknowledgments for the First Edition (2005)
    8. Acknowledgments for the Second Edition (2015)
    9. We Want to Hear from You!
    10. Reader Services
    11. Introduction
      1. Audience for This Book
      2. About the Second Edition
      3. Conventions Used in This Book
    12. Part I: Getting Started
      1. 1. Things to Know About Your Command Line
        1. Everything Is a File
        2. Maximum Filename Lengths
        3. Names Are Case-Sensitive
        4. Special Characters to Avoid in Names
        5. Wildcards and What They Mean
        6. Special Files That Affect Your Command Line
        7. If There’s Too Much Stuff on Screen, Reset
        8. Conclusion
      2. 2. Navigating Your File System
        1. List Files and Folders
        2. List the Contents of Other Folders
        3. List Folder Contents Using Wildcards
        4. View a List of Files in Subfolders
        5. View a List of Contents in a Single Column
        6. View Contents As a Comma-Separated List
        7. View Hidden Files and Folders
        8. Visually Display a File’s Type
        9. Display Contents in Color
        10. List Permissions, Ownership, and More
        11. Reverse the Order Contents Are Listed
        12. Sort Contents by Date and Time
        13. Sort Contents by Size
        14. Express File Sizes in Terms of K, M, and G
        15. Display the Path of Your Current Directory
        16. Change to a Different Directory
        17. Change to Your Home Directory
        18. Change to Your Previous Directory
        19. Conclusion
      3. 3. Creation and Destruction
        1. Change a File to the Current Time
        2. Change a File to Any Desired Time
        3. Create a New, Empty File
        4. Create a New Directory
        5. Create a New Directory and Any Necessary Subdirectories
        6. Copy Files
        7. Copy Files Using Wildcards
        8. Copy Files Verbosely
        9. Stop Yourself from Copying over Important Files
        10. Copy Directories
        11. Copy Files As Perfect Backups in Another Directory
        12. Move Files and Folders
        13. Rename Files and Folders
        14. Understand How Linux Stores Files
        15. Create a Link Pointing to Another File or Directory
        16. Delete Files
        17. Remove Several Files at Once with Wildcards
        18. Prevent Yourself from Deleting Key Files
        19. Delete an Empty Directory
        20. Remove Files and Directories That Aren’t Empty
        21. Deleting Troublesome Files
        22. Conclusion
      4. 4. Learning About Commands
        1. Find Out About Commands with man
        2. Quickly Find Out What a Command Does Based on Its Name
        3. Search for a Command Based on What It Does
        4. Read a Command’s Specific Man Page
        5. Learn About Commands with info
        6. Navigate Within info
        7. Locate the Paths for a Command’s Executable, Source Files, and Man Pages
        8. Find Out Which Version of a Command Will Run
        9. Discover How a Command Will Be Interpreted
        10. Conclusion
      5. 5. Building Blocks
        1. Run Several Commands Sequentially
        2. Run Commands Only If the Previous Ones Succeed
        3. Run a Command Only If the Previous One Fails
        4. Plug the Output of a Command into Another Command
        5. Understand Input/Output Streams
        6. Use the Output of One Command As Input for Another
        7. Redirect a Command’s Output to a File
        8. Prevent Overwriting Files When Using Redirection
        9. Append a Command’s Output to a File
        10. Use a File As Input for a Command
        11. Combine Input and Output Redirection
        12. Send Output to a File and to stdout at the Same Time
        13. Conclusion
    13. Part II: Working with Files
      1. 6. Viewing (Mostly Text) Files
        1. Figure Out a File’s Type
        2. View Files on stdout
        3. Concatenate Files to stdout
        4. Concatenate Files to Another File
        5. Concatenate Files and Number the Lines
        6. View Text Files a Screen at a Time
        7. Search Within Your Pager
        8. Edit Files Viewed with a Pager
        9. View the First 10 Lines of a File
        10. View the First 10 Lines of Several Files
        11. View the First Several Lines of a File or Files
        12. View the First Several Bytes, Kilobytes, or Megabytes of a File
        13. View the Last 10 Lines of a File
        14. View the Last 10 Lines of Several Files
        15. View the Last Several Lines of a File or Files
        16. View the Constantly Updated Last Lines of a File or Files
        17. Conclusion
      2. 7. Manipulating Text Files with Filters
        1. Count the Number of Words, Lines, and Characters in a File
        2. Number Lines in a File
        3. Select an Entire Column of Data in a Delimited File
        4. Sort the Contents of a File
        5. Sort the Contents of a File Numerically
        6. Remove Duplicate Lines in a File
        7. Substitute Selected Characters with Others
        8. Replace Repeated Characters with a Single Instance
        9. Delete Matching Characters
        10. Transform Text in a File
        11. Print Specific Fields in a File
        12. Conclusion
      3. 8. Ownerships and Permissions
        1. Become Another User
        2. Become Another User, with His Environment Variables
        3. Become root
        4. Become root, with Its Environment Variables
        5. Change the Group Owning Files and Directories
        6. Recursively Change the Group Owning a Directory
        7. Change the Owner of Files and Directories
        8. Change the Owner and Group of Files and Directories
        9. Understand the Basics of Permissions
        10. Change Permissions on Files and Directories Using Alphabetic Notation
        11. Change Permissions on Files and Directories Using Numeric Permissions
        12. Change Permissions Recursively
        13. Set and Then Clear suid
        14. Set and Then Clear sgid
        15. Set and Then Clear the Sticky Bit
        16. Conclusion
      4. 9. Archiving and Compression
        1. Archive and Compress Files Using zip
        2. Get the Best Compression Possible with zip
        3. Archive and Compress Files of a Specified Type in Directories and Subdirectories
        4. Password-Protect Compressed Zip Archives
        5. Unzip Files
        6. Test Files That Will Be Unzipped
        7. Archive and Compress Files Using gzip
        8. Archive and Compress Files Recursively Using gzip
        9. Uncompress Files Compressed with gzip
        10. Test Files That Will Be Unzipped with gunzip
        11. Archive and Compress Files Using bzip2
        12. Uncompress Files Compressed with bzip2
        13. Test Files That Will Be Unzipped with bunzip2
        14. Archive Files with tar
        15. Archive and Compress Files with tar and gzip
        16. Test Files That Will Be Untarred and Uncompressed
        17. Untar and Uncompress Files
        18. Conclusion
    14. Part IIII: Finding Files, Words, and More
      1. 10. Finding Files, Directories, Words, and Phrases
        1. Search a Database of Filenames
        2. Search a Database of Filenames Without Worrying About Case
        3. Update the Database Used by locate
        4. Searching Inside Text Files for Patterns
        5. The Basics of Searching Inside Text Files for Patterns
        6. Search Recursively for Text in Files
        7. Search for Words and Highlight the Results
        8. Search for Text in Files, Ignoring Case
        9. Search for Whole Words in Files
        10. Show Line Numbers Where Words Appear in Files
        11. Search the Output of Other Commands for Specific Words
        12. See Context for Words Appearing in Files
        13. Show Lines Where Words Do Not Appear in Files
        14. List Files Containing Searched-for Words
        15. List the Number of Occurrences of Words in Files
        16. Search for Words Inside Search Results
        17. Conclusion
      2. 11. The find Command
        1. Find Files by Name
        2. Find Files by Ownership
        3. Find Files by File Size
        4. Find Files by File Type
        5. Find Files by Time
        6. Show Results If the Expressions Are True (AND)
        7. Show Results If Either Expression Is True (OR)
        8. Show Results If the Expression Is Not True (NOT)
        9. Execute a Command on Found Files
        10. Execute a Command on Found Files More Efficiently
        11. Execute a Command on Found Files Containing Spaces
        12. Conclusion
    15. Part IV: Your Environment
      1. 12. Your Shell
        1. View Your Command-Line History
        2. Run the Last Command Again
        3. Run a Previous Command Using Numbers
        4. Run a Previous Command Using a String
        5. Search for a Previous Command and Run It
        6. Display All Command Aliases
        7. View a Specific Command Alias
        8. Create a New Temporary Alias
        9. Create a New Permanent Alias
        10. Remove an Alias
        11. Create a New Temporary Function
        12. Create a New Permanent Function
        13. Display All Functions
        14. Remove a Function
        15. When to Use an Alias and When to Use a Function
        16. Conclusion
      2. 13. Monitoring System Resources
        1. Discover How Long Your Computer Has Been Running
        2. View All Currently Running Processes
        3. View a Process Tree
        4. View Processes Owned by a Particular User
        5. End a Running Process
        6. View a Dynamically Updated List of Running Processes
        7. List Open Files
        8. List a User’s Open Files
        9. List Users for a Particular File
        10. List Processes for a Particular Program
        11. Display Information About System RAM
        12. Show File System Disk Usage
        13. Report File Space Used by a Directory
        14. Report Just the Total Space Used for a Directory
        15. Conclusion
      3. 14. Installing Software
        1. Install Software Packages (RPM)
        2. Remove Software Packages (RPM)
        3. Install Software Packages and Dependencies (RPM)
        4. Remove Software Packages and Dependencies (RPM)
        5. Upgrade Software Packages and Dependencies (RPM)
        6. Find Packages Available for Download (RPM)
        7. Install Software Packages (DEB)
        8. Remove Software Packages (DEB)
        9. Install Software Packages and Dependencies (DEB)
        10. Remove Software Packages and Dependencies (DEB)
        11. Upgrade Software Packages and Dependencies (DEB)
        12. Find Packages Available for Download (DEB)
        13. Clean Up Unneeded Installation Packages (DEB)
        14. Troubleshoot Problems with APT (DEB)
        15. Conclusion
    16. Part V: Networking
      1. 15. Connectivity
        1. View the Status of Your Network Interfaces
        2. Verify That a Computer Is Running and Accepting Requests
        3. Trace the Route Packets Take Between Two Hosts
        4. Query DNS Records
        5. Configure a Network Interface
        6. View the Status of Your Wireless Network Interfaces
        7. Configure a Wireless Network Interface
        8. Grab a New Address Using DHCP
        9. Make a Network Connection Active
        10. Bring a Network Connection Down
        11. Display Your IP Routing Table
        12. Change Your IP Routing Table
        13. Troubleshooting Network Problems
        14. Conclusion
      2. 16. Working on the Network
        1. Securely Log In to Another Computer
        2. Securely Log In to Another Machine Without a Password
        3. Securely Transfer Files Between Machines
        4. Securely Copy Files Between Hosts
        5. Securely Transfer and Back Up Files
        6. Download Files Non-interactively
        7. Download Websites Non-interactively
        8. Download Sequential Files and Internet Resources
        9. Conclusion
    17. Index
    18. Code Snippets