You are previewing Mac OS X Tiger for Unix Geeks, 3rd Edition.
O'Reilly logo
Mac OS X Tiger for Unix Geeks, 3rd Edition

Book Description

If you're one of the many Unix developers drawn to Mac OS X for its Unix core, you'll find yourself in surprisingly unfamiliar territory. Unix and Mac OS X are kissing cousins, but there are enough pitfalls and minefields in going from one to another that even a Unix guru can stumble, and most guides to Mac OS X are written for Mac aficionados. For a Unix developer, approaching Tiger from the Mac side is a bit like learning Russian by reading the Russian side of a Russian-English dictionary. Fortunately, O'Reilly has been the Unix authority for over 25 years, and in Mac OS X Tiger for Unix Geeks, that depth of understanding shows. This is the book for Mac command-line fans. Completely revised and updated to cover Mac OS X Tiger, this new edition helps you quickly and painlessly get acclimated with Tiger's familiar-yet foreign-Unix environment. Topics include:

  • Using the Terminal and understanding how it differs from an xterm

  • Using Directory Services, Open Directory (LDAP), and NetInfo

  • Compiling code with GCC 3

  • Library linking and porting Unix software

  • Creating and installing packages with Fink

  • Using DarwinPorts

  • Search through metadata with Spotlight's command-line utilities

  • Building the Darwin kernel

  • Running X Windows on top of Mac OS X, or better yet, run Mac OS X on a Windows machine with PearPC!

  • Mac OS X Tiger for Unix Geeks is the ideal survival guide for taming the Unix side of Tiger. If you're a Unix geek with an interest in Mac OS X, you'll find this clear, concise book invaluable.

    Table of Contents

    1. Special Upgrade Offer
    2. Preface
      1. Audience for This Book
      2. Organization of This Book
      3. Xcode Tools
      4. Where to Go for More Information
      5. Conventions Used in This Book
      6. Comments and Questions
      7. Safari Enabled
      8. Acknowledgments from the Previous Editions
      9. Acknowledgments from Brian Jepson
      10. Acknowledgments from Ernest E. Rothman
    3. I. Getting Around
      1. 1. Inside the Terminal
        1. 1.1. Mac OS X Shells
        2. 1.2. The Terminal and xterm Compared
        3. 1.3. Using the Terminal
          1. 1.3.1. Launching Terminals
            1. 1.3.1.1. .term files
            2. 1.3.1.2. .command files
          2. 1.3.2. Split Screen Terminal Feature
          3. 1.3.3. Contextual Menu
        4. 1.4. Customizing the Terminal
          1. 1.4.1. Customizing the Terminal on the Fly
          2. 1.4.2. Working with File and Directory Names
            1. 1.4.2.1. Tab completion
          3. 1.4.3. Changing Your Shell
        5. 1.5. The Services Menu
        6. 1.6. Bonjour
        7. 1.7. Alternative Terminal Applications
        8. 1.8. The open Command
      2. 2. Searching and Metadata
        1. 2.1. Spotlight
          1. 2.1.1. Performing Spotlight Searches
          2. 2.1.2. Inspecting a File’s Attributes
          3. 2.1.3. Managing Spotlight
        2. 2.2. Resource Forks and HFS+ Metadata
          1. 2.2.1. UFS
          2. 2.2.2. Preserving Metadata
      3. 3. The Mac OS X Filesystem
        1. 3.1. Working with Foreign Filesystems
        2. 3.2. Files and Directories
          1. 3.2.1. The /etc Directory
          2. 3.2.2. The /System/Library Directory
          3. 3.2.3. The /Library Directory
          4. 3.2.4. The /var Directory
          5. 3.2.5. The /dev Directory
      4. 4. Startup
        1. 4.1. Booting Mac OS X
          1. 4.1.1. The BootX Loader
          2. 4.1.2. Initialization
          3. 4.1.3. The /etc/rc Script
          4. 4.1.4. Mach Bootstrap Services
          5. 4.1.5. launchd
          6. 4.1.6. SystemStarter
          7. 4.1.7. The Login Window
        2. 4.2. Adding Startup Items
          1. 4.2.1. Login Preferences
          2. 4.2.2. Startup Items
            1. 4.2.2.1. The startup script
            2. 4.2.2.2. The property list
        3. 4.3. Scheduling Tasks
          1. 4.3.1. Periodic Jobs
      5. 5. Directory Services
        1. 5.1. Understanding Directory Services
        2. 5.2. Programming with Directory Services
          1. 5.2.1. Working with Passwords
        3. 5.3. Configuring Directory Services
        4. 5.4. NetInfo Manager
        5. 5.5. Directory Services Utilities
        6. 5.6. Managing Groups
          1. 5.6.1. Creating a Group with niload
          2. 5.6.2. Creating a Group with dscl
          3. 5.6.3. Adding Users to a Group
          4. 5.6.4. Listing Groups with nidump
          5. 5.6.5. Deleting a Group
        7. 5.7. Managing Users and Passwords
          1. 5.7.1. Creating a User with niload
          2. 5.7.2. Creating a User with dscl
          3. 5.7.3. Creating a User’s Home Directory
          4. 5.7.4. Granting Administrative Privileges
          5. 5.7.5. Modifying a User
          6. 5.7.6. Listing Users with nidump
          7. 5.7.7. Deleting a User
        8. 5.8. Managing Hostnames and IP Addresses
          1. 5.8.1. Creating a Host with niload
        9. 5.9. Exporting Directories with NFS
        10. 5.10. Flat Files and Their Directory Services Counterparts
        11. 5.11. Restoring the Directory Services Database
      6. 6. Printing
        1. 6.1. Printer Setup Utility
          1. 6.1.1. Adding an IP Printer
          2. 6.1.2. Modifying a Printer’s Settings
          3. 6.1.3. Creating a Desktop Icon for a Printer
          4. 6.1.4. Printer Sharing
        2. 6.2. Common Unix Printing System (CUPS)
          1. 6.2.1. Printing from Remote Systems
            1. 6.2.1.1. GNOME
            2. 6.2.1.2. KDE
            3. 6.2.1.3. Manual printer configuration (Linux and Unix)
            4. 6.2.1.4. Printing from Linux
        3. 6.3. Gimp-Print
          1. 6.3.1. HP InkJet Server (HPIJS) Project
      7. 7. The X Window System
        1. 7.1. Installing X11
        2. 7.2. Running X11
        3. 7.3. Customizing X11
          1. 7.3.1. Dot-files, Desktops, and Window Managers
          2. 7.3.2. X11 Preferences, Application Menu, and Dock Menu
            1. 7.3.2.1. Input
            2. 7.3.2.2. Output
            3. 7.3.2.3. Customizing X11’s Applications menu
        4. 7.4. X11-based Applications and Libraries
          1. 7.4.1. Aqua-X11 Interactions
          2. 7.4.2. TKAqua
        5. 7.5. Connecting to Other X Window Systems
          1. 7.5.1. OSX2X
        6. 7.6. Virtual Network Computing
          1. 7.6.1. Launching VNC
            1. 7.6.1.1. VNC and SSH
          2. 7.6.2. Connecting to the Mac OS X VNC Server
      8. 8. Multimedia
        1. 8.1. Burning CDs
        2. 8.2. Video
          1. 8.2.1. Open Source Video Players
        3. 8.3. Image Editing
        4. 8.4. 3D Modeling
      9. 9. Third-Party Tools and Applications
        1. 9.1. Virtual Desktops and Screens
        2. 9.2. The Application Menu
        3. 9.3. Exposé
        4. 9.4. Virtual Desktops
          1. 9.4.1. VirtualDesktop
          2. 9.4.2. Virtual Screens
        5. 9.5. SSH GUIs
          1. 9.5.1. LaTeX
          2. 9.5.2. Installing TeX Live-teTeX
          3. 9.5.3. TeXShop
          4. 9.5.4. iTeXMac
          5. 9.5.5. LaTeX Services
        6. 9.6. R with an Aqua GUI
        7. 9.7. NeoOffice/J and OpenOffice
      10. 10. Dual-Boot and Beyond
        1. 10.1. Why Bother?
        2. 10.2. Linux on Mac Hardware
          1. 10.2.1. Picking a Linux Distribution
          2. 10.2.2. Compatibility Details
          3. 10.2.3. Partitioning for Linux
          4. 10.2.4. Booting into Linux
          5. 10.2.5. Mac-on-Linux
        3. 10.3. Emulators on Mac OS X
          1. 10.3.1. Virtual PC
            1. 10.3.1.1. Linux doesn’t find the network adapter
            2. 10.3.1.2. Linux can’t configure TCP/IP
            3. 10.3.1.3. Launching X11 displays garbage on the screen
          2. 10.3.2. QEMU
            1. 10.3.2.1. Installing an operating system
            2. 10.3.2.2. Suspending and resuming
            3. 10.3.2.3. Networking
        4. 10.4. Emulating the Mac
          1. 10.4.1. PearPC
    4. II. Building Applications
      1. 11. Compiling Source Code
        1. 11.1. Compiler Differences
        2. 11.2. Compiling Unix Source Code
          1. 11.2.1. The First Line of Defense
          2. 11.2.2. Host Type
            1. 11.2.2.1. Macros
          3. 11.2.3. Supported Languages
          4. 11.2.4. Preprocessing
          5. 11.2.5. Frameworks
            1. 11.2.5.1. Framework structure
            2. 11.2.5.2. Including a framework in your application
          6. 11.2.6. Compiler Flags
        3. 11.3. Architectural Issues
          1. 11.3.1. AltiVec
          2. 11.3.2. 64-bit Computing
          3. 11.3.3. Endian-ness
          4. 11.3.4. Inline Assembly
        4. 11.4. X11-based Applications and Libraries
          1. 11.4.1. Building X11-based Applications and Libraries
          2. 11.4.2. AquaTerm
        5. 11.5. Xgrid
      2. 12. Libraries, Headers, and Frameworks
        1. 12.1. Header Files
          1. 12.1.1. Precompiled Header Files
          2. 12.1.2. malloc.h
          3. 12.1.3. poll.h
          4. 12.1.4. wchar.h and iconv.h
          5. 12.1.5. dlfcn.h
          6. 12.1.6. alloc.h
          7. 12.1.7. lcyrpt.h
          8. 12.1.8. values.h
        2. 12.2. The System Library: libSystem
        3. 12.3. libstdc++
        4. 12.4. Shared Libraries Versus Loadable Modules
          1. 12.4.1. Building a Shared Library
          2. 12.4.2. Dynamically Loading Libraries
          3. 12.4.3. Two-Level Namespaces
        5. 12.5. Library Versions
        6. 12.6. Creating and Linking Static Libraries
        7. 12.7. Creating Frameworks
        8. 12.8. The Dynamic Linker dyld: Prebinding, the Pre-Tiger Way
          1. 12.8.1. Launching an Application Built Without Prebinding
          2. 12.8.2. Tiger’s dyld Renders Prebinding Unnecessary
          3. 12.8.3. Some New Features of dyld
        9. 12.9. Performance Tools and Debugging Tools
        10. 12.10. CHUD Tools
        11. 12.11. Interesting and Important Libraries
        12. 12.12. Numerical Libraries
    5. III. Working with Packages
      1. 13. Fink
        1. 13.1. Installing Fink
          1. 13.1.1. Installing Fink from a Disk Image
          2. 13.1.2. Installing Fink from Source
          3. 13.1.3. Installing Fink from CVS
          4. 13.1.4. Post-Installation Setup
        2. 13.2. Using Fink
        3. 13.3. FinkCommander
        4. 13.4. Installing Binaries
      2. 14. DarwinPorts
        1. 14.1. Installing DarwinPorts
          1. 14.1.1. Installing DarwinPorts from CVS
        2. 14.2. Using DarwinPorts
          1. 14.2.1. Creating and Installing Packages in pkg Format
          2. 14.2.2. Creating and Installing Packages in RPM Format
        3. 14.3. DarwinPorts Maintenance
        4. 14.4. Installing Binaries
        5. 14.5. DPGUI
      3. 15. Creating and Installing Packages
        1. 15.1. Using PackageMaker
          1. 15.1.1. Setting up the Directory
          2. 15.1.2. Creating the Package
        2. 15.2. Using GNU tar
        3. 15.3. Disk Images
          1. 15.3.1. Creating a Disk Image with Disk Utility
          2. 15.3.2. Creating a Disk Image from the Command Line
          3. 15.3.3. Distributing Your Image
            1. 15.3.3.1. Internet-enabled disk images
        4. 15.4. Creating Fink Packages
          1. 15.4.1. Creating and Publishing the Tarball
          2. 15.4.2. Creating the .info File
          3. 15.4.3. Installing the Package
        5. 15.5. Creating DarwinPorts Packages
          1. 15.5.1. Creating and Publishing the Tarball
          2. 15.5.2. Creating the Portfile File
          3. 15.5.3. Building and Installing a Port
    6. IV. Serving and System Management
      1. 16. Using Mac OS X as a Server
        1. 16.1. Getting Connected
          1. 16.1.1. Dynamic DNS
          2. 16.1.2. Serving from Behind a Firewall
            1. 16.1.2.1. Port mapping with an AirPort Base Station
        2. 16.2. Built-in Services: The Sharing Panel
          1. 16.2.1. Personal File Sharing
          2. 16.2.2. Windows File Sharing
          3. 16.2.3. Personal Web Sharing
            1. 16.2.3.1. dav_module (mod_dav)
            2. 16.2.3.2. perl_module (mod_perl)
            3. 16.2.3.3. ssl_module (mod_ssl)
            4. 16.2.3.4. php4_module (mod_php4)
            5. 16.2.3.5. hfs_apple_module (mod_hfs_apple)
            6. 16.2.3.6. bonjour_module (mod_bonjour)
          4. 16.2.4. Remote Login
          5. 16.2.5. FTP Access
          6. 16.2.6. Printer Sharing
        3. 16.3. Email
          1. 16.3.1. Configuring Postfix to Send Email
          2. 16.3.2. Configuring Postfix to Receive Email
        4. 16.4. The Mac OS X Firewall
          1. 16.4.1. Internet Sharing
            1. 16.4.1.1. ifconfig
            2. 16.4.1.2. ipfw/natd
            3. 16.4.1.3. bootpd
            4. 16.4.1.4. named
          2. 16.4.2. The Mac OS X Firewall
            1. 16.4.2.1. Enable Firewall Logging
            2. 16.4.2.2. Block UDP Traffic
            3. 16.4.2.3. Enable Stealth Mode
          3. 16.4.3. Add Your Own Rules
      2. 17. System Management Tools
        1. 17.1. Diagnostic Utilities
          1. 17.1.1. top
          2. 17.1.2. fs_usage
          3. 17.1.3. latency
          4. 17.1.4. sc_usage
          5. 17.1.5. vm_stat
        2. 17.2. Kernel Utilities
          1. 17.2.1. ddb
          2. 17.2.2. ktrace
          3. 17.2.3. Kernel Module Utilities
          4. 17.2.4. sysctl
        3. 17.3. System Configuration
          1. 17.3.1. scutil
          2. 17.3.2. defaults
          3. 17.3.3. nvram
        4. 17.4. Third-Party Applications
      3. 18. Free Databases
        1. 18.1. SQLite
          1. 18.1.1. Where to Find SQLite
          2. 18.1.2. Using SQLite
        2. 18.2. MySQL
          1. 18.2.1. Compiling MySQL
          2. 18.2.2. Installing MySQL
          3. 18.2.3. Configuring MySQL
          4. 18.2.4. Using MySQL
        3. 18.3. PostgreSQL
          1. 18.3.1. Compiling PostgreSQL
          2. 18.3.2. Installing PostgreSQL
          3. 18.3.3. Adding the Startup Item
          4. 18.3.4. Configuring PostgreSQL
          5. 18.3.5. Using PostgreSQL
        4. 18.4. PHP and Perl
      4. 19. Perl and Python
        1. 19.1. Perl for Mac OS X Geeks
          1. 19.1.1. Mac::Carbon
          2. 19.1.2. PerlObjCBridge.pm
          3. 19.1.3. Mac::Glue
        2. 19.2. Python for Mac OS X Geeks
          1. 19.2.1. Carbon
          2. 19.2.2. Apple Events
          3. 19.2.3. PyObjC
    7. V. Appendixes
      1. A. Mac OS X GUI Primer
      2. B. Mac OS X’s Unix Development Tools
        1. B.1. Standard Unix Development Tools
        2. B.2. Apple’s Command-Line Developer Tools
        3. B.3. Macintosh Tools
        4. B.4. Java Development Tools
        5. B.5. Text Editing and Processing
        6. B.6. Scripting and Shell Programming
        7. B.7. Working with Files and Directories
        8. B.8. File Compression and Storage
        9. B.9. Searching and Sorting
        10. B.10. Miscellaneous Tools
    8. About the Authors
    9. Index
    10. About the Authors
    11. Colophon
    12. Special Upgrade Offer
    13. Copyright