2005/06/04
Helping a switcher (2: terminal tools)
As an introduction, read http://www.kernelthread.com/mac/osx/ , which is a really good summary of OS X from an "Unix" point of view.
The Ars Technica review is also a very good read for 10.4 improvements.
The Apple Developer Connection also has some interesting documentations, check Mac OS X Technology Overview, Porting UNIX/Linux Applications to Mac OS X or Security Overview.
Some OS X specific command line tools (see also this list by Amit Singh):
- Monitoring your system and apps:
fs_usage,ktrace,vm_stat,latency. With Developer Tools installed, the Shark application is a must-try. - Single most useful terminal command
/usr/bin/open. This command takes an argument and has the same effect than double-clicking the given file or directory in the finder. So you can typeopen mypict.jpgand have it open in your default viewer application (as set in the Finder information preferences), oropen http://www.apple.comthat will trigger the default URL scheme handler. The-aflag is quite useful, check the man page. - You can also manipulate clipboard information from the shell with
pbcopyandpbpaste.screencapturecan also be useful. - Lost in libraries ?
otool -Lis the equivalent of the beloved Linuxldd - Exploring the hardware ? There is command-lines alternative to the IOKit Explorer or Apple System Profiler:
system_profilerandioreg. You can also check the manpage forsysctlto fine-tune your system.pmsetcan also be helpful to tweak power management settings. Check alsohostinfoanduname -a - Speaking about command-line equivalent for GUI tools,
hdituilis the terminal equivalent of the Disk Utility application. Unified tool to burn, create , convert, compact, segment, manipulate disk images (CD, DVD, ISO images...). Oh, and burn these, too. - One little secret: the powerful Spotlight tool introduced in 10.4 is also available at terminal-level, and it's a really powerful tool. Think locate on steroids. It's
mdfind, check the manpage for detailed info. - A very interesting addition in 10.4 is "launchd" the new unified daemon/agent manager. Check the manpages for
launchd,launchd.plist,launchctl. This a very interesting replacement for cron/xinetd/rc.d etc. Might look weird when coming from a classic Unix background, but this brings very, very interesting features (fine job control, user/system unification, etc). There's a doc on ADC. - X11 ? Why would you need X11 as you already have Quartz. Ok, ok, I installed it too. Note that for a few years, X11 is shipped by Apple in Mac OS X, but as an optional install. Think about it and click on the "customize" button when installing your OS. If you already have OS X in place, you can still install it. Open your installation DVD, the packages are usually in
/System/Library/Installationand there are two packages, X11User.pkg and X11SDK.pkg (headers and tools). A final trick: the/usr/bin/open-x11is a nice shortcut to launch a X11 application, it will automatically start the X11 server is needed. - The I/O Kit registry is the closest thing to the
/prochierarchy on Linux. The IOKit is the 'driver level' in OS X, a neat efficient, object-oriented driver model, architectured with energy management in mind. Try for instanceioreg -lto display the whole registry with object properties. -
/usr/bin/say hello