You are previewing SAMS Teach Yourself Unix in 24 Hours FOURTH EDITION.
O'Reilly logo
SAMS Teach Yourself Unix in 24 Hours FOURTH EDITION

Book Description

If you're in need of a tutorial to learn UNIX from the ground up, this is it. Sams Teach Yourself UNIX in 24 Hours, Fourth Edition will let you experience UNIX through hands-on tutorials divided into 24 one-hour lessons so that you can learn the most common UNIX tasks at your own pace. The author will guide you through the basics of maintaining and manipulating a UNIX/Linux operating system. This hands-on approach will allow you to work through the exercises and grasp common UNIX/Linux concepts, including:

  • Using the Command Line

  • Listing Files and Managing Disk Usage

  • Slicing and Dicing Command Pipe

  • Shell Programming

  • Printing in the UNIX Environment

  • Using telnet, ssh, and ftp

  • Perl Programming in UNIX

  • Gain the fundamental knowledge you need to begin working with UNIX with the help of Sams Teach Yourself UNIX in 24 Hours, Fourth Edition.

    Table of Contents

    1. Copyright
      1. Dedication
    2. About the Author
    3. Acknowledgments
    4. Tell Us What You Think!
      1. Reader Services
    5. Introduction
      1. Does Each Chapter Take an Hour?
      2. What If I Take Longer Than 24 Hours?
      3. Are There Really 24 Hours Worth of Lessons?
      4. How to Use This Book
        1. Main Section
        2. Tasks
        3. Workshops
    6. 1. What Is This Unix Stuff?
      1. Goals for This Hour
      2. What Is Unix?
      3. A Brief History of Unix
        1. The C Programming Language
        2. Unix Becomes Popular
      4. What's All This About Multiuser Systems?
      5. Cracking Open the Shell
      6. Getting Help
        1. Task 1.1: Man Pages, Unix Online Reference
        2. Task 1.2: Other Ways to Find Help in Unix
      7. Summary
      8. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    7. 2. Getting onto the System and Using the Command Line
      1. Goals for This Hour
      2. Beginning Your Session
        1. Task 2.1: Logging In and Out of the System
        2. Task 2.2: Changing Passwords with passwd
        3. Task 2.3: Picking a Secure Password
      3. 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
      4. Summary
      5. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    8. 3. Moving About the File System
      1. Goals for This Hour
      2. 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
      3. Directory Separator Characters
      4. 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
      5. Summary
      6. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    9. 4. Listing Files and Managing Disk Usage
      1. Goals for This Hour
      2. 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
      3. 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
      4. 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
      5. Summary
      6. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    10. 5. Ownership and Permissions
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    11. 6. Creating, Moving, Renaming, and Deleting Files and Directories
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    12. 7. Looking into Files
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    13. 8. Filters, Pipes, and Wildcards!
      1. Goals for This Hour
      2. 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 in a File 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    14. 9. Slicing and Dicing Command-Pipe Data
      1. Goals for This Hour
      2. The awk Programming System
        1. Task 9.1: Learning to Use awk
      3. How to Use cut in Pipes
        1. Action 9.2: Slicing and Dicing with cut
      4. Inline Editing with sed and tr
        1. Action 9.3: Inline Editing with sed and tr
      5. Summary
      6. Workshop
        1. Exercises
        2. Preview of the Next Hour
    15. 10. An Introduction to the vi Editor
      1. Goals for This Hour
      2. Editing the Unix Way
        1. Task 10.1: How to Start and Quit 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 into the File Using i, a, o, and O
        5. Task 10.5: Deleting Text
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    16. 11. Advanced vi Tricks, Tools, and Techniques
      1. Goals for This Hour
      2. 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: How to Start vi Correctly
        4. Task 11.4: Search and Replace
        5. Task 11.5: The Change and Replace Commands
        6. Task 11.6: Accessing Unix with !
      3. Summary of vi Commands
      4. Summary
      5. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    17. 12. An Overview of the emacs Editor
      1. Goals for This Hour
      2. The Other Popular Editor: emacs
        1. Task 12.1: Launching emacs and Inserting Text
        2. Task 12.2: How to Move Around in a File
        3. Task 12.3: How to Delete Characters and Words
        4. Task 12.4: Search and Replace in emacs
        5. Task 12.5: Using the emacs Tutorial and Help System
        6. Task 12.6: Working with Other Files
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    18. 13. Introduction to Command Shells
      1. Goals for This Hour
      2. The (Command) Shell Game
        1. Task 13.1: What Shells Are Available?
        2. Task 13.2: Identifying Your Shell
        3. Task 13.3: How to Choose a New Shell
        4. Task 13.4: Learning the Shell Environment
        5. Task 13.5: Exploring bash Configuration Files
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    19. 14. Advanced Shell Interaction
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    20. 15. Job Control
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    21. 16. Shell Programming Overview
      1. Goals for This Hour
      2. Build 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    22. 17. Advanced Shell Programming
      1. Goals for This Hour
      2. 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: How Much Disk Space Do We Have Left?
        4. Task 17.4: Let's Play a (Shell Script) Game!
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    23. 18. Printing in the Unix Environment
      1. Goals for This Hour
      2. Making a Printed Copy
        1. Task 18.1: Find Local Printers with printers
        2. Task 18.2: Printing Files with lpr or lp
        3. Task 18.3: Formatting Print Jobs with pr and col
        4. Task 18.4: Working with the Print Queue
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    24. 19. Archives and Backups
      1. Goals for This Hour
      2. The tar Tape Archive Utility
        1. Task 19.1: Learning to Use tar
      3. Shrinking Your Files with compress
        1. Action 19.2: Shrinking Large Files on Unix
      4. Exploring the Unix Tape Command: cpio
        1. Action 19.3: A Quick Exploration of cpio
      5. Personal Backup Solutions
        1. Action 19.4: A Personal Backup Scheme
      6. Working with Unix Package Managers
        1. Action 19.5: A Visit with the RPM Package Manager
      7. Summary
      8. Workshop
        1. Exercises
        2. Preview of the Next Hour
    25. 20. Communicating with Email
      1. Goals for This Hour
      2. 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: Internet Email Addresses
        4. Task 20.4: The Smarter Electronic Mail Alternative, elm
        5. Task 20.5: A Glimpse of Pine
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    26. 21. Using telnet, SSH, and ftp
      1. Goals for This Hour
      2. Stepping Beyond Your Own System
        1. Task 21.1: Connecting to Remote Internet Sites
        2. Task 21.2: Telnet from Windows and Macs
        3. Task 21.3: Secure Connections with SSH
        4. Task 21.4: Copying Files with FTP
        5. Task 21.5: Exploring Anonymous FTP Archives
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    27. 22. Searching for Information and Files
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Exercises
        2. Preview of the Next Hour
    28. 23. Perl Programming in Unix
      1. Goals for This Hour
      2. 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
      3. Summary
      4. Workshop
        1. Key Terms
        2. Exercises
        3. Preview of the Next Hour
    29. 24. GNOME and the GUI Environment
      1. Goals for This Hour
      2. Tweaking Your Inner GNOME
        1. Task 24.1: Getting Started with X11 and GNOME
        2. Task 24.2: Fine-tuning Your GNOME Configuration
      3. Working with GNOME Applications
        1. Task 24.3: Working with OpenOffice.org
        2. Task 24.4: The Firefox Web Browser
        3. Task 24.5: Using the Evolution Email Program
      4. Summary
      5. Congratulations!
      6. Workshop
        1. Key Terms
        2. Exercises
    30. 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 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
    31. B. Working with the Apache Web Server
      1. Goals for This Hour
      2. Working with a Unix Web Server
        1. Task B.1: Exploring Apache Configuration Files
        2. Task B.2: Creating a Simple CGI Program
        3. Task B.3: A Server-Side Include Program
        4. Task B.4: Understanding Apache Log Files
      3. Summary
      4. Workshop
        1. Key Terms