You are previewing Unix in 24 Hours, Sams Teach Yourself: Covers OS X, Linux, and Solaris, Fifth Edition.
O'Reilly logo
Unix in 24 Hours, Sams Teach Yourself: Covers OS X, Linux, and Solaris, Fifth Edition

Book Description

Learn to use Unix, OS X, or Linux quickly and easily!

In just 24 lessons of one hour or less, Sams Teach Yourself Unix in 24 Hours helps you get up and running with Unix and Unix-based operating systems such as Mac OS X and Linux.

Designed for beginners with no previous experience using Unix, this book’s straightforward, step-by-step approach makes it easy to learn.

Each lesson clearly explains essential Unix tools and techniques from the ground up, helping you to become productive as quickly and efficiently as possible.

  • Step-by-step instructions carefully walk you through the most common Unix tasks.

  • Practical, hands-on examples show you how to apply what you learn.

  • Quizzes and exercises help you test your knowledge and stretch your skills.

  • Notes and tips point out shortcuts and solutions

  • Learn how to

  • Pick the command shell that’s best for you

  • Organize the Unix file system (and why)

  • Manage file and directory ownership and permissions

  • Maximize your productivity with power filters and pipes

  • Use the vi and emacs editors

  • Create your own commands and shell scripts

  • Connect to remote systems using SSH and SFTP

  • Troubleshoot common problems

  • List files and manage disk usage

  • Get started with Unix shell programming

  • Set up printing in a Unix environment

  • Archive and back up files

  • Search for information and files

  • Use Perl as an alternative Unix programming language

  • Set up, tweak, and make use of the GNOME graphical environment

  • Contents at a Glance


    HOUR 1: What Is This Unix Stuff?

    HOUR 2: Getting onto the System and Using the Command Line

    HOUR 3: Moving About the File System

    HOUR 4: Listing Files and Managing Disk Usage

    HOUR 5: Ownership and Permissions

    HOUR 6: Creating, Moving, Renaming, and Deleting Files and Directories

    HOUR 7: Looking into Files

    HOUR 8: Filters, Pipes, and Wildcards!

    HOUR 9: Slicing and Dicing Command-Pipe Data

    HOUR 10: An Introduction to the vi Editor

    HOUR 11: Advanced vi Tricks, Tools, and Techniquess

    HOUR 12: An Overview of the emacs Editor

    HOUR 13: Introduction to Command Shells

    HOUR 14: Advanced Shell Interaction

    HOUR 15: Job Control

    HOUR 16: Shell Programming Overview

    HOUR 17: Advanced Shell Programming

    HOUR 18: Printing in the Unix Environment

    HOUR 19: Archives and Backups

    HOUR 20: Using Email to Communicate

    HOUR 21: Connecting to Remote Systems Using SSH and SFTP

    HOUR 22: Searching for Information and Files

    HOUR 23: Perl Programming in Unix

    HOUR 24: GNOME and the GUI Environment

    Appendix A: Common Unix Questions and Answers

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. About the Author
    7. Dedication
    8. Acknowledgments
    9. We Want to Hear from You!
    10. Reader Services
    11. Introduction
      1. Does Each Chapter Take an Hour?
      2. What if I Take Longer Than 24 Hours?
      3. How to Use This Book
        1. Main Section
        2. Tasks
        3. Workshops
    12. Hour 1. What Is This Unix Stuff?
      1. What Is Unix?
      2. A Brief History of Unix
        1. The C Programming Language
        2. Unix Becomes Popular
      3. What’s All This About Multiuser Systems?
      4. Cracking Open the Shell
      5. Getting Help
        1. Task 1.1: Man Pages, Unix Online Reference
        2. Task 1.2: Other Ways to Find Help in Unix
      6. Summary
      7. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    13. Hour 2. Getting onto the System and Using the Command Line
      1. Beginning Your Session
        1. Task 2.1: Logging In to and Out of the System
        2. Task 2.2: Changing Passwords with passwd
        3. Task 2.3: Picking a Secure Password
      2. Seeing What’s Going On Around You
        1. Task 2.4: Who Are You?
        2. Task 2.5: Finding Out What Other Users Are Logged In to the System
        3. Task 2.6: What Is Everyone Doing on the Computer?
        4. Task 2.7: Checking the Current Date and Time
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    14. Hour 3. Moving About the File System
      1. What a Hierarchical File System Is All About
        1. Task 3.1: The Unix File System Organization
        2. The bin Directory
        3. The dev Directory
        4. The etc Directory
        5. The lib Directory
        6. The lost+found Directory
        7. The mnt and sys Directories
        8. The tmp Directory
        9. The usr Directory
        10. Other Miscellaneous Stuff at the Top Level
      2. Directory Separator Characters
      3. The Difference Between Relative and Absolute Filenames
        1. Task 3.2: Hidden Files in Unix
        2. Task 3.3: The Special Directories . and ..
        3. Task 3.4: The env Command
        4. Task 3.5: PATH and HOME
        5. Task 3.6: Find Where You Are with pwd
        6. Task 3.7: Moving to Another Location with cd
      4. Summary
      5. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    15. Hour 4. Listing Files and Managing Disk Usage
      1. The ls Command
        1. Task 4.1: All About the ls Command
        2. Task 4.2: Having ls Tell You More
        3. Task 4.3: Combining Flags
        4. Task 4.4: Listing Other Directories Without Changing Location
      2. Special ls Command Flags
        1. Task 4.5: Changing the Sort Order in ls
        2. Task 4.6: Listing Directory Trees Recursively in ls
        3. Task 4.7: Long Listing Format in ls
      3. Permissions Strings
        1. Task 4.8: Long Listing Format for Directories in ls
        2. Task 4.9: Creating Files with the touch Command
        3. Task 4.10: Checking Disk Space Usage with du
        4. Task 4.11: Checking Available Disk Space with df
        5. Task 4.12: Shrinking Big Files with the gzip Program
      4. Summary
      5. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    16. Hour 5. Ownership and Permissions
      1. Working with File Permissions
        1. Task 5.1: Understanding File Permissions Settings
        2. Task 5.2: Directory Permissions Settings
        3. Task 5.3: Modifying File and Directory Permissions with chmod
        4. Task 5.4: Setting New File Permissions with chmod
        5. Task 5.5: Calculating Numeric Permissions Strings
        6. Task 5.6: Establishing Default File and Directory Permissions with the umask Command
        7. Task 5.7: Identifying Owner and Group for Any File or Directory
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    17. Hour 6. Creating, Moving, Renaming, and Deleting Files and Directories
      1. Manipulating the Unix File System
        1. Task 6.1: Creating New Directories Using mkdir
        2. Task 6.2: Copying Files to New Locations Using cp
        3. Task 6.3: Moving Files to New Locations Using mv
        4. Task 6.4: Renaming Files with mv
        5. Task 6.5: Removing Directories with rmdir
        6. Task 6.6: Removing Files Using rm
        7. Task 6.7: Minimizing the Danger of the rm Command
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    18. Hour 7. Looking into Files
      1. Looking Inside Files
        1. Task 7.1: Using file to Identify File Types
        2. Task 7.2: Exploring Unix Directories with file
        3. Task 7.3: Peeking at the First Few Lines with head
        4. Task 7.4: Viewing the Last Few Lines with tail
        5. Task 7.5: Viewing the Contents of Files with cat
        6. Task 7.6: Viewing Larger Files with more
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    19. Hour 8. Filters, Pipes, and Wildcards!
      1. Maximizing the Command Line
        1. Task 8.1: The Secrets of File Redirection
        2. Task 8.2: Counting Words and Lines Using wc
        3. Task 8.3: Sorting Information Using sort
        4. Task 8.4: Filename Wildcards
        5. Task 8.5: Searching Files with grep
        6. Task 8.6: Creating Regular Expressions
        7. Task 8.7: The Rest of the grep Family
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    20. Hour 9. Slicing and Dicing Command-Pipe Data
      1. The awk Programming System
        1. Task 9.1: Learning to Use awk
      2. How to Use cut in Pipes
        1. Action 9.2: Slicing and Dicing with cut
      3. Inline Editing with sed and tr
        1. Action 9.3: Inline Editing with sed and tr
      4. Summary
      5. Workshop
        1. Exercises
        2. Preview of the Next Hour
    21. Hour 10. An Introduction to the vi Editor
      1. Editing the Unix Way
        1. Task 10.1: Starting and Quitting vi
        2. Task 10.2: Simple Cursor Motion in vi
        3. Task 10.3: Moving by Words and Pages
        4. Task 10.4: Inserting Text Using i, a, o, and O
        5. Task 10.5: Deleting Text
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    22. Hour 11. Advanced vi Tricks, Tools, and Techniques
      1. Advanced Editing with vi
        1. Task 11.1: Searching Within a File
        2. Task 11.2: The Colon Commands in vi
        3. Task 11.3: Starting vi Correctly
        4. Task 11.4: Searching and Replacing
        5. Task 11.5: Using the Change and Replace Commands
        6. Task 11.6: Accessing Unix with !
      2. Summary of vi Commands
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    23. Hour 12. An Overview of the emacs Editor
      1. The Other Popular Editor: emacs
        1. Task 12.1: Launching emacs and Inserting Text
        2. Task 12.2: Moving Around in a File
        3. Task 12.3: Deleting Characters and Words
        4. Task 12.4: Searching and Replacing in emacs
        5. Task 12.5: Using the emacs Tutorial and Help System
        6. Task 12.6: Working with Other Files
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    24. Hour 13. Introduction to Command Shells
      1. The (Command) Shell Game
        1. Task 13.1: What Shells Are Available?
        2. Task 13.2: Identifying Your Shell
        3. Task 13.3: Choosing a New Shell
        4. Task 13.4: Learning the Shell Environment
        5. Task 13.5: Exploring bash Configuration Files
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    25. Hour 14. Advanced Shell Interaction
      1. Which Shell Is Which?
        1. Task 14.1: The Shell History Mechanisms
        2. Task 14.2: Using History to Cut Down on Typing
        3. Task 14.3: Command Aliases
        4. Task 14.4: Some Power Aliases
        5. Task 14.5: Setting Custom Prompts
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    26. Hour 15. Job Control
      1. Wrestling with Your Jobs
        1. Task 15.1: Job Control in the Shell: Stopping Jobs
        2. Task 15.2: Foreground/Background and Unix Programs
        3. Task 15.3: Finding Out What Tasks Are Running
        4. Task 15.4: Terminating Processes with kill
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    27. Hour 16. Shell Programming Overview
      1. Building Your Own Commands
        1. Task 16.1: Shell Variables
        2. Task 16.2: Shell Arithmetic
        3. Task 16.3: Comparison Functions
        4. Task 16.4: Conditional Expressions
        5. Task 16.5: Looping Expressions
        6. Task 16.6: bash Functions
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    28. Hour 17. Advanced Shell Programming
      1. Searching a Database of Filenames with mylocate
        1. Task 17.1: Building mylocate
        2. Task 17.2: How Many Commands Do You Have?
        3. Task 17.3: Who Is Using All the Disk Space?
        4. Task 17.4: Let’s Play a (Shell Script) Game!
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    29. Hour 18. Printing in the Unix Environment
      1. Making a Printed Copy
        1. Task 18.1: Finding Local Printers with lpstat
        2. Task 18.2: An Introduction to CUPS
        3. Task 18.3: Printing Files with lpr or lp
        4. Task 18.4: Formatting Print Jobs with pr and col
        5. Task 18.5: Working with the Print Queue
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    30. Hour 19. Archives and Backups
      1. The tar Tape Archive Utility
        1. Task 19.1: Learning to Use tar
      2. The zip Archive Utility
        1. Task 19.2: Learning to Use zip
      3. Shrinking Your Files with compress
        1. Action 19.3: Shrinking Large Files on Unix
      4. Exploring the Unix Tape Command: cpio
        1. Action 19.4: A Quick Exploration of cpio
      5. Personal Backup Solutions
        1. Action 19.5: A Personal Backup Scheme
      6. Working with Linux Package Managers
      7. Summary
      8. Workshop
        1. Exercises
        2. Preview of the Next Hour
    31. Hour 20. Using Email to Communicate
      1. Interacting with the World
        1. Task 20.1: Reading Electronic Mail with mailx
        2. Task 20.2: Sending Mail from the Command Line
        3. Task 20.3: Sending Email to the Rest of the World
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    32. Hour 21. Connecting to Remote Systems Using SSH and SFTP
      1. Stepping Beyond Your Own System
        1. Task 21.1: Connecting to Remote Internet Sites with SSH
        2. Task 21.2: Third-Party SSH Connections
        3. Task 21.3: Copying Files with SFTP
        4. Task 21.4: Exploring Anonymous FTP Archives
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    33. Hour 22. Searching for Information and Files
      1. Finding What’s Where
        1. Task 22.1: The find Command and Its Weird Options
        2. Task 22.2: Using find with xargs
        3. Task 22.3: Getting Files from the Internet
      2. Summary
      3. Workshop
        1. Exercises
        2. Preview of the Next Hour
    34. Hour 23. Perl Programming in Unix
      1. Flexible and Powerful: Perl
        1. Task 23.1: Exchange, a Demonstration Currency Translator Written in Perl
        2. Task 23.2: Checking Code Quality with -w
        3. Task 23.3: Online Perl Documentation and Information
        4. Task 23.4: Other Useful Perl Commands
      2. Summary
      3. Workshop
        1. Key Terms
        2. Exercises
    35. Hour 24. GNOME and the GUI Environment
      1. Tweaking Your Inner GNOME
        1. Task 24.1: Fine-tuning Your GNOME Configuration
      2. Working with GNOME Applications
        1. Task 24.2: Working with the GNOME File Browser
        2. Task 24.3: The Firefox Web Browser
        3. Task 24.4: Using Thunderbird for Email
      3. Summary
        1. Congratulations!
      4. Workshop
        1. Key Terms
        2. Exercises
    36. Appendix A. Common Unix Questions and Answers
      1. How do I use find|xargs with filenames that contain spaces?
      2. How do I find large files on my system?
      3. How do I run a program on a schedule?
        1. The at Command
        2. cron
      4. How do I fix file permission problems?
      5. How do I list files that don’t match a given pattern?
      6. How do I view lines X–Y in a text file?
      7. How do I add a new directory to my PATH?
      8. How do I recover deleted files?
      9. How can I set my shell to protect me from accidental deletions?
      10. What do the shell errors arg list too long and broken pipe mean?
      11. Why use ssh instead of telnet? Or sftp instead of ftp?
      12. Summary
    37. Index
    38. Code Snippets