17.4. Third-Party Applications

 < Day Day Up > 

17.3. System Configuration

Although you can perform most system configuration through the System Preferences program, the scutil and defaults commands let you poke around under the hood. You can get even further under the hood with the nvram command (perhaps further than most people would need or want to get).

17.3.1. scutil

Mac OS X stores network configuration in a database called the dynamic store. You can get at this database using scutil, the system configuration utility. Before you can do anything, you must connect to the configuration daemon (configd) with the open command (close the session with the close command, and exit scutil with quit):

     Chez-Jepstone:~ bjepson$ sudo scutil     Password: ********     > open 

List the contents (a collection of keys) of the configuration database with the list command. The following shows abbreviated output from this command:

     > list       subKey [0] = DirectoryService:PID       subKey [1] = Plugin:IPConfiguration       subKey [2] = Setup:       subKey [3] = Setup:/       subKey [4] = Setup:/Network/Global/IPv4       subKey [5] = Setup:/Network/HostNames       subKey [6] = Setup:/Network/Interface/en1/AirPort       subKey [7] = Setup:/Network/Service/48A67922-40FB-4FE0-B475-DEB8D9B2665C 

You can show the contents of a key with the show command. The contents of a key are stored as a dictionary (key/value pairs). For example, here are the default proxy settings for built-in Ethernet on Mac OS X (to verify that Service shows a UserDefinedName of Built-in Ethernet, you should use show Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Interface you will probably need to replace 8D89866C-BFF5-4965-8BE8-A55DCDD4169F with a value obtained from the list command shown earlier):

     > show Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Proxies     <dictionary> {       ExcludeSimpleHostnames : 0       AppleProxyConfigurationSelected : 2       ProxyAutoDiscoveryEnable : 0       FTPPassive : 1     }       

Here are the proxy settings for a Mac OS X machine that's been configured to use a proxy server:

     > show Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Proxies     <dictionary> {       FTPPassive : 1       ProxyAutoDiscoveryEnable : 0       ExcludeSimpleHostnames : 0       HTTPProxy :       HTTPPort : 80       AppleProxyConfigurationSelected : 2       HTTPEnable : 1     }       

To change an entry, lock the database, initialize an empty dictionary entry with d.init, and get the current values of the key you want to change:

     > lock     > d.init     > get Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Proxies 

Make your changes to the dictionary, then check them with d.show:

     > d.add HTTPPort 8888     > d.add HTTPProxy proxy.nowhere.oreilly.com     > d.show     <dictionary> {       FTPPassive : 1       ProxyAutoDiscoveryEnable : 0       ExcludeSimpleHostnames : 0       HTTPProxy : proxy.nowhere.oreilly.com       HTTPPort : 8888       AppleProxyConfigurationSelected : 2       HTTPEnable : 1     } 

Currently, these changes are not kept permanently. To make permanent changes, use the System Preferences Network user interface.

If you are happy with the dictionary values, set the key (this copies the dictionary into the specified key), unlock the database, and examine the key:

     > set Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Proxies     > unlock     > show Setup:/Network/Service/8D89866C-BFF5-4965-8BE8-A55DCDD4169F/Proxies     <dictionary> {       FTPPassive : 1       ProxyAutoDiscoveryEnable : 0       ExcludeSimpleHostnames : 0       HTTPProxy : proxy.nowhere.oreilly.com       HTTPPort : 8888       AppleProxyConfigurationSelected : 2       HTTPEnable : 1     } 

Be careful while the database is locked. If you try to do something seemingly innocuous, such as switching network locations, you could cause the system to behave erratically. It's best to get in and out of the database as quickly as possible.

17.3.2. defaults

When you customize your Mac using the System Preferences, most of those changes and settings are stored in what's known as the defaults system. Nearly everything that you've done to make your Mac your own is stored as a property list (or plist). This property list is, in turn, stored in ~/Library/Preferences.

Every time you change one of those settings, that particular property list is updated. For the initiated, there is another way to alter the property lists: use the Property List Editor application (/Developer/Applications/Utilities) and the other is by using the defaults command in the Terminal. Whether you use System Preferences , or the defaults command, any changes you make affect the current user.

Using the defaults command is not for the foolhardy. If you manage to mangle your settings, the easiest way to correct the problem is to go back to that application's Preferences pane and reset your preferences. In some cases, you can use defaults delete, which will be reset to the same defaults when you next log in. Since the defaults command affects only the current user, you could also create a user just for testing random defaults tips you pick up on the Internet.

Here are some examples of what you can do with the defaults command. For more information, see the manpage.

View all of the user defaults on your system

     $ defaults domains 

This command prints a listing of all of the domains in the user's defaults system. The list you'll see is run together with spaces in between not quite the prettiest way to view the information.

View the settings for the Dock:

     $ defaults read com.apple.dock 

This command reads the settings from the com.apple.dock.plist file, found in ~/Library/Preferences.

Change your Dock's default location to the top of the screen

     $ defaults write com.apple.dock orientation top 

This command moves the Dock to the top of the screen underneath the menu bar. After changing this setting, you'll need to logout from the system and then log back in to see the Dock under the menu bar.

17.3.3. nvram

The nvram utility modifies Open Firmware variables, which control the boot-time behavior of your Macintosh. To list all Open Firmware variables, use nvram -p. The Apple Open Firmware page is http://bananajr6000.apple.com/.

To change a variable, you must run nvram as root or as the superuser. To set a variable, use variable=value. For example, to configure Mac OS X to boot verbosely, use nvram boot-args=-v. (Booting into Mac OS 9 or earlier will reset this variable.) Table 17-7 lists Open Firmware variables. Some variables use the Open Firmware Device Tree notation (see the technotes available at the Apple Open Firmware page).

Be careful changing the nvram utility, since incorrect settings can turn an iMac G5 into a $2000 doorstop. If you render your computer unbootable, you can reset Open Firmware by zapping the PRAM. To zap the PRAM, hold down Option--P-R as you start the computer, and then release the keys when you hear a second startup chime. (If your two hands are busy holding down the other buttons and you have trouble reaching the power button, remember that you can press it with your nose.)

Table 17-7. nvram variables




The automatic boot settings. If TRue (the default), Open Firmware will automatically boot an operating system. If false, the process will stop at the Open Firmware prompt. Be careful using this with Old World (unsupported) machines and third-party graphics adapters, since the display and keyboard may not be initialized until the operating system starts (in which case, you will not have access to Open Firmware).


The arguments that are passed to the boot loader.


The command that starts the boot process. The default is mac-boot, an Open Firmware command that examines the boot-device for a Mac OS startup.


The device to boot from. The syntax is device:[partition],path:filename, and a common default is hd:,\\: tbxi. In the path, \\ is an abbreviation for /System/Library/CoreServices, and tbxi is the file type of the BootX boot loader. (Run /Developer/Tools/GetFileInfo on BootX to see its type.)


The name of the boot loader. (This is often blank, since boot-command and boot-device are usually all that are needed.)


The image to display on the boot screen.


A variable that can contain an Open Firmware boot script.


Unknown or undocumented.


A variable that specifies the console output device, using an Open Firmware Device Tree name.

default-client- ip

An IP address for diskless booting.

default-gateway- ip

A gateway address for diskless booting.

default-mac- address?

Unknown or undocumented.

default-router- ip

A router address for diskless booting.

default-server- ip

An IP address for diskless booting.

default-subnet- mask

A default subnet mask for diskless booting.


A private variable; not usable for security reasons.


A private variable; not usable for security reasons.


A private variable; not usable for security reasons.


A variable that determines whether the Open Firmware Forth interpreter will display extra debugging information.


The input device to use for the Open Firmware console.


A secondary input device (so you can have a screen and serial console at the same time). Use scca for the first serial port.


The CPU endianness. If true, initializes the PowerPC chip as little endian. The default is false.


A private variable; not usable for security reasons.


The mouse device using an Open Firmware Device Tree name.


A sequence of commands to execute at boot time (if use-nvramc? is set to true).


A custom banner to display at boot time.


The oem banner settings. Set to true to enable the oem banner. The default is false.


A 64-by-64 bit array containing a custom black-and-white logo to display at boot time. This should be specified in hex.


The oem logo settings. Set to TRue to enable the oem logo. The default is false.


The device to use as the system console. The default is screen.


A secondary output device (so you can have everything go to both the screen and a serial console). Use scca for the first serial port.


A private variable; not usable for security reasons.


The amount of RAM currently installed. For example, 256 MB is shown as 0x10000000.


The starting physical address that is available to Open Firmware.


The address translation settings. If true, Open Firmware will use real-mode address translation. Otherwise, it uses virtual-mode address translation.


The size of the physical address space available to Open Firmware.


The number of columns for the system console.


The number of rows for the system console.


Set by page checking output words to prevent Open Firmware text from scrolling off the top of the screen.


The number of MB of RAM to test at boot time. The default is 0.


The device node naming settings. Specifies whether to use generic device node names such as "screen," as opposed to Apple hardware code names.


The command settings. If this is true, Open Firmware uses the commands in nvramrc at boot time.


The starting virtual address that is available to Open Firmware.


The size of the virtual address space available to Open Firmware.

     < Day Day Up > 

    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net