Mac OS X 10.5 includes a number of changes to its Unix core, perhaps more than in any prior OS X release. Many of the changes are routine—updated versions of key Unix programs such as the bash shell (from 2.0.5b to 3.2), the vi text editor (from version 6.2 to 7.0), and even the man manual page reader (from 1.5o1 to 1.6c). Most of these alterations, however, will be invisible to the casual Terminal user—though the new versions may contain some additional features, the programs will still work as they did before.
More interesting are the totally new (or substantially revised) Unix commands in 10.5. Here are my picks for the five most interesting and useful ones.
Those pesky dot-underscore files
If you’ve ever used a USB memory stick to move files to a Windows or Linux machine, or written files to a server that doesn’t use the Mac’s HFS file system, you’re probably familiar with the “dot-underscore files” that are created when you do so; depending on what you did to the files and/or folders on the Mac, you will see any number of file names that begin with dot-underscore (._), followed by the names of the other folders on the disk. The Mac uses these files on its HFS disk, but they are useless on other systems.
Prior to 10.5, you had to manually delete them on the other system, or use Terminal trickery to remove them on the Mac prior to copying. As of 10.5, though, you can just use the dot_clean command on the directory in question. Type dot_clean /path/folder to join the dot-underscore files with their parent files. Read OS X 10.5’s manual pages (man dot_clean ) for more information.
Learn about kernel extensions
Kernel extensions (also known as kexts) are low-level pieces of code that talk directly to the heart of the Mac operating system. They are powerful and potentially dangerous: if there’s a bug in a kernel extension, it can crash your Mac. (At worst, a buggy program can crash only itself.) In 10.5, you can use the kextfind command to find out which kernel extensions are on your machine.
Most of the kernel extensions on your Mac are bundled with OS X; you can see exactly what’s installed by using the command kextfind -case-insensitive -bundle-id -substring 'com.apple.' -print | more .
While that command may look intimidating, it’s actually pretty straightforward. The -case-insensitive argument tells the system to find all matches, regardless of capitalization. Next, -bundle-id and -substring tell kextfind to look for the text string ‘com.apple. ’ in the extension’s bundle identifier. The -print switch tells kextfind to output the results to the screen, while | more tells Terminal to pause after each page of output. You can see a list of third-party kernel extensions by inserting -not and a space before -bundle-id in the command above.
Just because an extension is listed, however, doesn’t mean it’s active. To see which of your third-party extensions are active, type kextfind -loaded -not -bundle-id -substring ‘com.apple. ‘ | more . This is similar to the other command, with the addition of the -loaded flag, which tells it to list only those extensions that are currently active.
If you’re experiencing kernel panics, this list is a good place to start looking for suspects; if you see a likely candidate, try removing the device or program associated with the extension and then rebooting. If your kernel panics vanish, you’ve found the source of the problem. The man kextfind manual pages have a lot of good examples of other uses for this command.
Dig into installer packages
Apple’s installer keeps track of things it installs—you can see everything it’s done by looking at the /Library/Receipts folder. From there, you can dig into packages and see what’s been installed. However, rooting around in that folder by hand isn’t much fun—it requires lots of cd and lsbom commands. OS X 10.5’s new pkgutil command simplifies things.
To see a list of installed packages, just type pkgutil —pkgs and press return. Each entry in the list represents a package ID; you can use that string to get more information on any particular package. For instance, if you’d like to know every file that was installed with the recent security update, just type the following (but without the line breaks), and then press return:
pkgutil —files com.apple.pkg.update.security.2007.009 | more
Set System and Network Preferences
OS X 10.5 has two utilities, systemsetup and networksetup , that allow you to view and configure various network and machinewide System Preferences settings. These programs aren’t new in 10.5—they were available in 10.4, too. But in 10.4, they were buried deep in the System folder. As of 10.5, Apple has placed them in a standard Unix folder, making them easily accessible to everyone.
So what can you do with them, and why would you want to do those things?
One way these programs are useful is in managing remote connections. Say you’ve used ssh to connect to a remote Mac. You might then need its Ethernet card’s MAC address to set up a router. To get that information, type sudo networksetup -getmacaddress en0 . (You need to type sudo to claim the administrative privileges required for these commands.) Want to see what network services are available on the remote Mac? Type networksetup -listallnetworkservices . You can then use the names of those services in other commands, such as the following, which displays the list of DNS servers on the remote Mac: sudo networksetup -getdnsservers "ethernet 1" . If you wanted to change those DNS servers, you’d use the -setdnsservers option.
The systemsetup command is similarly useful. For instance, you can see the settings for your computer and display system sleep times with systemsetup -getcomputersleep and systemsetup -getdisplaysleep . To change the display sleep setting to four minutes, you’d type systemsetup -displaysleep 4 .
You can see which of the disks start up a Mac by typing systemsetup -liststartupdisks ; also, you can change a startup disk with the -setstartupdisk option; you follow this option with the path to that disk’s CoreServices folder, as displayed in the -liststartupdisks option.
Both of these commands have lots of additional features—check out man systemsetup and man networksetup for a thorough explanation of all of their capabilities.
[Rob Griffiths is a senior editor at Macworld.]
Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read ouraffiliate link policyfor more details.