You are previewing MAC OS® X UNIX® Toolbox: 1000+ Commands for the Mac OS® X.
O'Reilly logo
MAC OS® X UNIX® Toolbox: 1000+ Commands for the Mac OS® X

Book Description

Explore a ton of powerful Mac OS X UNIX commands

This handy, compact guide teaches you to use Mac OS X UNIX systems as the experts do: from the command line. Try out more than 1,000 commands to find and get software, monitor system health and security, and access network resources. Apply the skills you learn from this book to troubleshoot networks, lock down security, and uncover almost anything you care to know about your Mac OS X system.

Expand your Mac OS X UNIX expertise in these and other areas:

  • Using the shell

  • Finding online software

  • Working with files

  • Playing with music and images

  • Administering file systems

  • Backing up data

  • Checking and managing running processes

  • Accessing network resources

  • Handling remote system administration

  • Locking down security

Table of Contents

  1. Copyright
  2. About the Authors
  3. Acknowledgments
  4. Introduction
    1. Who Should Read This Book
    2. What This Book Covers
    3. How This Book Is Structured
    4. What You Need to Use This Book
    5. Conventions
  5. 1. Starting with UNIX on Mac OS X
    1. 1.1. About FreeBSD, NetBSD, and OpenBSD
    2. 1.2. Finding Mac OS X Resources
    3. 1.3. Focusing on Mac OS X Commands
      1. 1.3.1. Finding Commands
      2. 1.3.2. Command Reference Information in UNIX
        1. 1.3.2.1. Using help Messages
        2. 1.3.2.2. Using man Pages
        3. 1.3.2.3. Using info Documents
    4. 1.4. Summary
  6. 2. New to Mac OS X?
    1. 2.1. What Is Mac OS X UNIX?
    2. 2.2. Finding Terminal and Utilities
    3. 2.3. Directory Structure
    4. 2.4. Your Home Directory
    5. 2.5. Spotlight
    6. 2.6. Getting and Using Fink
    7. 2.7. Mounting and Unmounting Drives
    8. 2.8. Learning to Love Launchd
    9. 2.9. Summary
  7. 3. Using the Shell
    1. 3.1. Terminal Windows and Shell Access
    2. 3.2. Using the Shell
      1. 3.2.1. Using bash History
      2. 3.2.2. Using Command-Line Completion
      3. 3.2.3. Redirecting stdin and stdout
      4. 3.2.4. Using Aliases
      5. 3.2.5. Tailing Files
    3. 3.3. Acquiring Super User Power
    4. 3.4. Using Environment Variables
    5. 3.5. Creating Simple Shell Scripts
      1. 3.5.1. Editing and Running a Script
      2. 3.5.2. Adding Content to Your Script
    6. 3.6. Summary
  8. 4. Working with Files
    1. 4.1. Understanding File Types
      1. 4.1.1. Using Regular Files
      2. 4.1.2. Using Directories
      3. 4.1.3. Using Symbolic and Hard Links
      4. 4.1.4. Using Device Files
      5. 4.1.5. Using Named Pipes and Sockets
    2. 4.2. Setting File and Directory Permissions
      1. 4.2.1. Changing Permissions with chmod
      2. 4.2.2. Setting the umask
      3. 4.2.3. Changing Ownership
    3. 4.3. Traversing the File System
    4. 4.4. Copying Files
    5. 4.5. Searching for Files
      1. 4.5.1. Generating the locate Database
      2. 4.5.2. Finding Files with locate
      3. 4.5.3. Locating Files with find
      4. 4.5.4. Using Other Commands to Find Files
    6. 4.6. Finding Out More About Files
      1. 4.6.1. Listing Files
      2. 4.6.2. Verifying Files
    7. 4.7. Summary
  9. 5. Manipulating Text
    1. 5.1. Matching Text with Regular Expressions
    2. 5.2. Editing Text Files
      1. 5.2.1. Using the Pico and Nano Editors
    3. 5.3. Listing, Sorting, and Changing Text
      1. 5.3.1. Listing Text Files
      2. 5.3.2. Paging Through Text
      3. 5.3.3. Paginating Text Files with pr
      4. 5.3.4. Searching for Text with grep
        1. 5.3.4.1. Checking Word Counts with wc
        2. 5.3.4.2. Sorting Output with sort
        3. 5.3.4.3. Finding Text in Binaries with Strings
      5. 5.3.5. Replacing Text with sed
      6. 5.3.6. Translating or Removing Characters with tr
      7. 5.3.7. Checking Differences Between Two Files with diff
      8. 5.3.8. Using awk and cut to Process Columns
    4. 5.4. Summary
  10. 6. Advanced Scripting
    1. 6.1. Shell Scripting on Mac OS X
      1. 6.1.1. Creating a Basic Shell Script
      2. 6.1.2. Adding Command-Line Arguments
      3. 6.1.3. Things to Watch Out For
    2. 6.2. Using the Script Command
    3. 6.3. AppleScripting
    4. 6.4. Working with the Open Command
    5. 6.5. Summary
  11. 7. Administering File Systems
    1. 7.1. Understanding File System Basics
      1. 7.1.1. Setting Up the Disk Initially
      2. 7.1.2. Checking Your Disk Setup
      3. 7.1.3. Understanding File System Types
    2. 7.2. Creating and Managing File Systems
      1. 7.2.1. Partitioning Hard Disks
      2. 7.2.2. A Better Option: Nondestructive Partitioning
    3. 7.3. Mounting and Unmounting File Systems
    4. 7.4. Checking File Systems
    5. 7.5. Finding Out About File System Use
    6. 7.6. Summary
  12. 8. Backups and Removable Media
    1. 8.1. Backing Up Data to Compressed Archives
      1. 8.1.1. Creating Backup Archives with tar
      2. 8.1.2. Using Compression Tools
        1. 8.1.2.1. Compressing with gzip
        2. 8.1.2.2. Compressing with bzip2
      3. 8.1.3. Listing, Joining, and Adding Files to tar Archives
    2. 8.2. Backing Up over a Network
      1. 8.2.1. Backing Up tar Archives over ssh
      2. 8.2.2. Backing Up Files with rsync
      3. 8.2.3. Backing Up to CD or DVD
      4. 8.2.4. Working with Time Machine and Time Capsule
    3. 8.3. Summary
  13. 9. Checking and Running Processes
    1. 9.1. Listing Active Processes
      1. 9.1.1. Viewing Active Processes with ps
      2. 9.1.2. Watching Active Processes with top
    2. 9.2. Finding and Controlling Processes
      1. 9.2.1. Using grep and pgrep to Find Processes
      2. 9.2.2. Using fuser to Find Processes
        1. 9.2.2.1. Adjusting Processor Priority with nice
        2. 9.2.2.2. Running Processes in the Background and Foreground
        3. 9.2.2.3. Killing and Signaling Processes
        4. 9.2.2.4. Running Processes Away from the Current Shell
        5. 9.2.2.5. Scheduling Processes to Run
    3. 9.3. Summary
  14. 10. Managing the System
    1. 10.1. Monitoring Resources
      1. 10.1.1. Monitoring Memory Use
      2. 10.1.2. Monitoring CPU Usage
      3. 10.1.3. Monitoring Storage Devices
    2. 10.2. Mastering Time
      1. 10.2.1. Changing Time Zone
      2. 10.2.2. Displaying and Setting Time and Date
      3. 10.2.3. Using Network Time Protocol to Set Date/Time
      4. 10.2.4. Checking Uptime
    3. 10.3. Starting and Stopping Your System
    4. 10.4. Straight to the Kernel
    5. 10.5. Summary
  15. 11. Managing Network Connections
    1. 11.1. Configuring Network Interfaces
    2. 11.2. Managing Network Interface Cards
    3. 11.3. Managing Network Connections
      1. 11.3.1. Starting and Stopping Network Connections
      2. 11.3.2. Starting and Stopping Network Services
    4. 11.4. Checking Name Resolution
    5. 11.5. Troubleshooting Network Problems
      1. 11.5.1. Checking Connectivity to a Host
      2. 11.5.2. Checking Address Resolution Protocol (ARP)
      3. 11.5.3. Tracing Routes to Hosts
      4. 11.5.4. Displaying netstat Connections and Statistics
    6. 11.6. Summary
  16. 12. Accessing Network Resources
    1. 12.1. Transferring Files
      1. 12.1.1. Downloading Files with wget
      2. 12.1.2. Transferring Files with curl
      3. 12.1.3. Transferring Files with FTP Commands
      4. 12.1.4. Using SSH Tools to Transfer Files
        1. 12.1.4.1. Copying Remote Files with scp
        2. 12.1.4.2. Copying Remote Files in sftp and lftp Sessions
    2. 12.2. Sharing Remote Directories
      1. 12.2.1. Sharing Remote Directories with NFS
        1. 12.2.1.1. Sharing Directories from an NFS Server
        2. 12.2.1.2. Viewing and Exporting NFS Shares
        3. 12.2.1.3. Mounting NFS Shares
      2. 12.2.2. Sharing Remote Directories with Samba
        1. 12.2.2.1. Viewing and Accessing Samba Shares
        2. 12.2.2.2. Mounting Samba Shares
        3. 12.2.2.3. Looking Up Samba Hosts
        4. 12.2.2.4. Checking Samba Configuration
    3. 12.3. Chatting with Friends in IRC
    4. 12.4. Using Text-Based E-mail Clients
    5. 12.5. Summary
  17. 13. Remote System Administration
    1. 13.1. Remote Login and Tunneling with SSH
      1. 13.1.1. Configuring SSH
      2. 13.1.2. Logging in Remotely with SSH
        1. 13.1.2.1. Accessing SSH on a Different Port
        2. 13.1.2.2. Using SSH to Do Tunneling (X11 Port Forwarding)
          1. 13.1.2.2.1. Tunneling for X11 Clients
          2. 13.1.2.2.2. Tunneling for CUPS Printing Remote Administration
          3. 13.1.2.2.3. Tunneling to an Internet Service
        3. 13.1.2.3. Using SSH with Public Key Authentication
          1. 13.1.2.3.1. Using Public Key Logins
          2. 13.1.2.3.2. Saving Private Keys to Use from a USB Flash Drive
    2. 13.2. Using screen: A Rich Remote Shell
      1. 13.2.1. Reconnecting to a screen Session
      2. 13.2.2. Naming screen Sessions
      3. 13.2.3. Sharing screen Sessions
    3. 13.3. Using a Remote Windows Desktop
    4. 13.4. Using Remote Desktop and Applications
    5. 13.5. Sharing Your Desktop Using VNC
    6. 13.6. Summary
  18. 14. Locking Down Security
    1. 14.1. Working with Users and Groups
    2. 14.2. Managing Users the GUI Way
    3. 14.3. Checking on Users
    4. 14.4. Configuring the Built-in Firewall
    5. 14.5. Working with System Logs
    6. 14.6. Summary
  19. A. Using vi or Vim Editors
    1. A.1. Starting and Quitting the vi Editor
    2. A.2. Moving Around in vi
    3. A.3. Changing and Deleting Text in vi
    4. A.4. Using Miscellaneous Commands
    5. A.5. Modifying Commands with Numbers
    6. A.6. Using Ex Commands
    7. A.7. Working in Visual Mode
    8. A.8. Summary
  20. B. Special Shell Characters and Variables
    1. B.1. Using Special Shell Characters
    2. B.2. Using Shell Variables
  21. C. Personal Configuration Files
  22. D. AppleScript Command Summary
  23. E. Fink Package Summary
  24. F. Perl Primer
    1. F.1. Introducing Perl
    2. F.2. Checking Links on a Website
      1. F.2.1. The Entire Script
      2. F.2.2. Initializing the Script and Loading Packages
      3. F.2.3. Targeting the URL and Extracting Links
      4. F.2.4. Processing the @links Array
      5. F.2.5. Running the Script
      6. F.2.6. Extending the Script