Some Useful and Interesting Terminal Commands for Lab Managers
/usr/sbin/softwareupdate
The softwareupdate command can be used to manually install software update packages from the command line.
The syntax is easy, just type softwareupdate to list available updates. The output looks something like this:
[bombich:~] softwareupdate
Software Update Tool
Copyright 2002 Apple Computer, Inc.
Software Update found the following new or updated software:
- AirPortSW-3.1.1
AirPort Software (3.1.1), 7940K - restart required
- Hard_Disk_Update_1-1.0
Hard Disk Update (1.0), 840K
- Java141Update1-1.4.1
Java (1.4.1), 40700K - restart required
- PowerMacSuperDriveUpdt-1.0
Power Mac SuperDrive Update (1.0), 2760K
To install an update, run this tool with the item name as an argument.
e.g. 'softwareupdate <item> ...'
Installing an update is easy, just type sudo softwareupdate
name. If you would like to install all software updates automatically,
you can create a cron task to do so. In the crontab, use the following command
as root:
softwareupdate -i -a
The above syntax works in Panther only (and probably anything newer). softwareupdate also
has a great man page now, check it out!
Also note that some updates may require that the user agree to a license
agreement or otherwise provide feedback. In a command-line automated
environment, this is unnacceptable. To get around this, execute the
following command or add this to your script before running softwareupdate:
setenv COMMAND_LINE_INSTALL 1 (if using csh or tcsh)
COMMAND_LINE_INSTALL=1 export COMMAND_LINE_INSTALL (if using bash or sh)
/usr/sbin/nvram
The nvram command can be used to list and set open firmware settings
such as the startup device. nvram could be very handy in an imaging
script: at the end of the script, you could use df to get the disk and
volume of the startup disk, then use (all one line)
nvram boot-device=/pci@f2000000/mac-io@17/ata-4@1f000/@${disk}:${vol},\\:tbxi
That exact string may not work for every mac out there, so I encourage
you to play with nvram -p to get a feel for what is available.
The "default-server-ip" setting in particular gets my heart racing --
what can it be used for? To set up a default Netboot server perhaps?
You can also specify your own settings. For example, you could create
a variable called asset_tag and keep the asset inventory
tag of that particular computer in the firmware. Later, remotely, you
can identify exactly what the machine is that you're dealing with using
the nvram command. You could also couple the nvram
command with the AppleSystemProfiler command to
set the serial number into the nvram. Cool.
/usr/sbin/bless
You can use the bless command to bless a System folder.
This is particularly useful if you want to install system software by
imaging rather than a standard installer. bless can also
be used to bless a Mac OS 9 system folder, which is handy if you need
to bootup Classic, but the system folder is not blessed. Finally, bless
can be used to set the startup disk from the command line!
/sbin/SystemStarter
SystemStarter is responsible for displaying the splash
screen with progress bar that lists the loading StartupItems when
the
computer boots. It is also responsible for loading the StartupItems
and determining the proper order to load them based on the settings
in
the individual StartupItem config files.
/etc/rc
This one isn't really a command, its a script, but its definitely worth mentioning. The /etc/rc script is the master startup script for Mac OS X. It initiates the network interface, mounts volumes, starts up virtual memory, the Window Server, the PasteBoard Server and kicks off the SystemStarter. If you want to spend a day hacking, take a look at this script -- there is much to be learned. For more information on Mac OS X's boot procedure, check out Apple's Documentation on it.
"ps -auxc" and System Daemons
The ps command lists the current processes (I happen to like to use the auxc flags). The function of many of the processes that run constantly in the background and are owned by root may not be entirely obvious. Fortunately, Apple has published information about these processes. Check out Apple's Documentation on it.
lsof and fstat
lsof and fstat list open files. This can be very handy for overcoming the "Cannot eject disk X because it is in use" error. Try:
fstat | grep volumeName
to get the list of files open on that volume.



