Mac OS X for Geeks
This is a list of pointers for newcomers to Mac OS X. It is mostly geared towards people coming from UNIX and UNIX-like environments.
Mac OS X is based on Darwin -- a BSD UNIX under the hood. Darwin has a number of subtle differences from traditional UNIX environments.
Orientation and Moving Around
- A Terminal emulator can be found in /Applications/Utilities.
- Many common software packages come with the the distribution, including ssh, emacs, perl, python, ruby, etc. Those that don't often build directly from source.
- Dragging a file or folder onto the Terminal will input the pathname to the shell.
- The
open
command will open a pathname as if it had been opened from the Finder. For example,open foo
will open the file foo with the appropriate helper.open .
will open a Finder window for the current directory. This is particularly useful when poking around areas of the file system which are otherwise hidden from the Finder. In addition, the -a flag causes the Finder to search for and open an application, e.g.open -a Terminal.app
(opens the first Terminal.app found, regardless of its location) oropen -a BBEdit.app ./foo.txt
(opens foo.txt from the current directory in the first BBEdit found). - "Classic" Mac apps are those compiled to run on Mac OS 9 or earlier. These don't work on Intel-based Macs and, in general, aren't used any more. However, some will still run under OS X on a PowerPC based Mac if you have the Classic environment (a hosted OS 9 runtime) installed. Older PowerPC based Macs can also boot into OS 9.
- "Universal" Mac apps are those compiled to run on both PowerPC and Intel based Macs. This is largely irrelevant, as Apple hasn't shipped a PowerPC based Mac in years. The exception is that modern versions of Mac OS X won't run PowerPC apps, so you may need to find an updated version of the app if you wish to run it.
- Most system "extensions" go in a subdirectory of /Library or ~/Library. Putting it in the former makes it available to everyone, in the latter just to that user. Apple-provided system extensions go into /System/Library. (n.b. "Extensions" sometimes refers to a specific type of OS X component that typically indicates use of a kernel extension, but many people use the term imprecisely, which can lead to confusion.)
Differences from other platforms
- Through version 10.7, Mac OS X ships with X11 (possibly as an optional install), but the default UI doesn't use it. Apple's X11 comes with a window manager that gives X apps Mac-style windows.
- Apps are a collection of files in a folder with the .app extension. The Finder knows what to do with these. If you want to poke around inside, select "Show Package Contents" from the contextual menu, or
cd
into them. Some apps with generic names are sometimes referred to by the full package name to indicate the mac specific version (e.g. "Mail.app"). - The system relies heavily on internal services for configuration, rather than static text files. Editing the standard UNIX configuration files may not have any effect, and is discouraged.
- Most of the normal UNIX file paths are hidden in the Finder. For example,
/usr/bin
is there, and accessible from the command line, but /usr doesn't show up in Finder views. - UNIX servers often have their config files in odd places within /Library.
- Darwin uses two boot systems: an older script-based boot system using directories of files stored in /System/Library/StartupItems and /Library/StartupItems (see here for more info) and a newer system built on dependency graphs, launchd, which is intended to replace all the various methods of automatically starting software in the environment. launchd has some limitations (in particular, it doesn't deal with apps that need to be shutdown via another process, such as apache with
apachectl
), but is otherwise a complete solution for launching software and managing what's running. - The default file system install is HFS+. UFS is also available as an option. There are upsides and downsides to both:
- HFS+ is a dual-fork journaled fs with metadata support. HFS+ is a fragmenting FS, although with hot-file clustering the need for explicit de-fragmentation is pretty low. By default HFS+ is case-insensitive but case-preserving. You can configure it as fully case-sensitive by reformatting, but this is a very uncommon configuration and many user apps will break.
- UFS is UFS. It doesn't fragment, but it doesn't have the dual fork support that various apps need.
- Command line tools (e.g.
ls
,mv
,tar
) have varying levels of support for HFS+ resource forks and metadata, so it pays to be careful when working with Mac files from the command line.
Configuring your environment
- The user default web browser and email client are defined in the preference panes of Apple's shipping applications (Safari and Mail, respectively). If you want to use different apps (e.g. Firefox and/or Thunderbird) you can use the Apple apps to define what gets opened for http:, https: and mailto: links. Alternatively you can use More Internet, a preference pane which lets you set most protocol handlers.
- Don't move apps which the system installs. Updaters may try to update blankly into the space where it thinks your app is, leaving you with half an updated app. Most third party developers use a "drag install" (move the app wherever you want, the app doesn't care), avoiding these problems. Apple is reputed to be working on an installer that tracks where you moved things, but for now that doesn't work.
- If you are using a laptop and take it with you, get to know the Locations submenu of the Apple menu. You can configure multiple logical sets of network configurations (e.g. "Home at Desk" (ethernet on, fixed IP nothing else), "Work" (ethernet with work's DHCP config and proxy server settings), "Bob's" (WiFi with Bob's network/security info), etc.), and switch between them quickly.
- You can move the dock to different sides of the screen. Third party apps like TinkerTool will let you pin it to the beginning or end of its orientation. Most people seem to wind up sticking it on the right in order to get more vertical space. Many also pin to the beginning (top, when on the side) so the dock doesn't jump around as much.
- The system firewall is available in the Security panel in System Preferences. Note that the Sharing panel will automatically poke holes in the firewall for services you enable. Note: the system firewall has many known holes. If you want to monitor and block outbound connections, get Little Snitch.
- A panel in System Preferences will let you set which apps to launch when you log in. In OS X 10.6 it's the "Login Items" tab under the "Accounts" panel, though the location changed in past releases. Note that this just deals with per-login-session items, not with background processes (servers, etc.) launched at boot time.
Maintenance and Troubleshooting
- The Software Update panel in System Preferences (and "Software Update..." menu item in the Apple menu) gets the latest OS and application updates. You can use it manually or set it up to check automatically on a daily, weekly or monthly schedule (sort of: you can't set the details of the schedule, just the period).
- OS X updates may step all over
/usr
,/etc
,/var
, etc., but should leave/usr/local
alone. Regardless, you may wish to avoid installing UNIX software into/usr
if you are building it yourself. - The built in disk utility has a "repair disk" function that runs fsck. You can also run fsck by booting in single-user mode. DiskWarrior is a third-party disk utility that is generally good at catching and fixing ugly disk problems.
- Yasu bundles many common maintenance tasks behind a fairly easy to use interface. It is especially worth getting if you're supporting other users. Of note: many of these tasks only solve a small number of specific problems, and are often compared to cargo-cult debugging. That said, taken together these tasks fix a large number of specific problems, so the tool turns out to be fairly useful.
- File system rot is not-uncommon (although far less common than it used to be). Try some combination of the following:
- Boot in single user mode and run fsck. This is equivalent to running the Disk Utility's First Aid function, although possibly a bit more effective.
- Boot from the install disk and run the Disk Utility app's First Aid function. (You might need to do this if you can't boot in single user mode or don't trust running it from the local disk.)
- Use DiskWarrior.
- Some installers and some applications can corrupt your file permissions on the disk, causing all sorts of quiet problems. Disk Utility has a function for repairing file permissions, and Yasu lets you run this function with less hassle. Many people feel that this is a voodoo fix, but they have yet to explain to me why I should not be concerned when secure.log is world readable, or the Applications directory is world-writeable.
- HFS+ volumes get fragmented, but as of OSX 10.3 the system defrags on the fly, and uses hot-file clustering to speed disk performance. Accordingly, it generally isn't worth de-fragmenting (and it often just makes things worse). If you must defragment, it's usually worth running DiskWarrior both before and after a de-fragmentation operation.
Software Notes
- The development environment (XCode) includes gcc and other standard development tools. As of XCode 4, the gcc is actually gcc-llvm, as Apple is moving the toolchain to an llvm-based toolchain. You can also get the most recent version via the App Store.
- Fink and MacPorts are package managers along the lines of the Ports collection. They both also have GUI front ends. Both these tools install things outside of /usr (Fink in /sw, DarwinPorts in /opt). Homebrew is a more bare-bones package manager designed for more technical users. It lets you pick where to install.
- Secrets lets you twiddle with various UI settings.
- OS X comes with iChat AV -- a video-conferencing and AIM client (the video-conferencing feature only works with other iChat AV clients). AOL ported its own AIM client for OS X, but hasn't updated it since February of 2004. Many people prefer Adium -- a small, fast, GPLd instant message client supporting most major IM protocols, as well as OTR encryption.
- Aquamacs is a port of Emacs that runs in the Mac UI layer.
- Video playback is kind of a mess. The system comes with QuickTime, although some features (such as MPEG-2 support) cost extra. You can get DivX and Flip4Mac's Windows Media codecs for QuickTime. VLC and MPlayer are third-party players which support a number of additional codecs. None of these alone will play everything, but all of them together will play most everything.
- The Mozilla apps (Firefox, Thunderbird, etc.) are available. They're supported but less well-integrated with the rest of the system. Camino is a project to wrap the Gecko browser engine (from Firefox) in a Mac UI, and integrate with the rest of the system.
- Microsoft Internet Explorer is no longer supported (some might argue it wasn't really supported when it was supported)
- Microsoft Office is available.
- TextMate is a popular text editor for Mac OS X that has been likened to Emacs for its extensibility and programmer-focus.
- BBEdit is another popular text editor for Mac OS X. TextWrangler is a free version of BBEdit (without many of the more powerful features).
- Little Snitch is an active firewall extension that lets you monitor and control outbound connections (e.g. the app "iThoughtThisWasNotSpyware.app wants to send to host badguy.com. allow?").
- The Safari Cookies, Safari Adblocker, and ClickToFlash extensions let you manage cookies, ads, and Flash components, respectively. Cookie is an app that lets you automatically mange cookies across many browsers, without patching the browser at runtime.
Boot Options
You can hold down various keys during boot to cause certain things to happen.
- option - bring up a list of volumes to boot from.
- c - boot from CD if available.
- t - boot as a firewire disk you can access from other machines.
- command-s - boot in single user mode.
- command-v - do a unix style scrolling text boot.
Sites to Visit
- MacFixIt - breakage, fixage
- MacOSXHints - tips and tricks
Blatant Plug
I run a mailing list, OSX Hack which is sort of a general "geeks using OS X" discussion forum. Topics range from the basic to the arcane. If you found this document useful you will probably get something out of the list.