MacOS X

10.4 Tiger

Open Firmware

configuration

  • nvram -p in the Terminal prints out Open Firmware configuration
  • sudo nvram name=value sets the value
  • press Option-Command-P-R while booting the machine for 'zapping the PRAM'
  • press Option-Command-O-F while booting to access Open Firmware command line
  • to reset Open Firmware and restart the system execute following commands: reset-nvram and then reset-all

booting

  • bless - sets volume bootability and startup disk options
  • hold down C key while booting to boot from a DVD
  • hold down N key while booting to boot from a NetBoot server
  • hold down T key to place your Mac into Target mode as mountable FireWire drive
  • hold down Option key while booting to see the local drives that contain a bootable partition (OS Picker)
  • hold down X key while booting to boot into MacOS X (if there is only one available)
  • hold down Command-S while booting to start MacOS X in single-user mode
  • hold down Command-V while booting to start MacOS X in verbose mode
  • hold down the Shift key to invoke Safe Boot mode
  • hold down Option key to open Startup Manager and select which OS to boot into
  • hold down mouse button to eject any disks or other removable media

booting MacOSX off USB drive

Here is the copy of the procedure found on the web

  • Using Disk Utility, prepare a USB disk by deleting everything on it and create an “Apple Partition Map”
  • Restore the MacOSX image onto the USB thumbdrive
  • Using Disk Utility, find out the partition on the USB key that holds the OS you want to restore (in my case : it was called disk1s3, the last figure holds the partition number thus : 3 )
  • Then you boot in the PowerBook OpenFirmware (the bootstrap that loads before MacOSX) by pressing the “Apple / Alt / O / F” keys at the same time right after you switch on the machine (before the chime sound)
  • Type dev / ls and try to find something like “/disk@1″ next to an entry named USB (in my case usb@1b,1)
  • Type DEVALIAS in the command prompt and locate the short name of the USB entry you just found using dev / ls (in my case usb0)
  • Make sure your USB key holds a file called “BootX” with the tbxi attribute by listing the directory. In the following command, disk@1 should be replaced by what you found in Step 5, also every character is important (this includes colon, forward slash, etc.). Type dir shortname_found_in_step_6/disk@1:partition_number_found_in_step_3,\System\Library\CoreServices (in my case dir usb0/disk@1:3,\System\Library\CoreServices)
  • If BootX is found with an attribute called tbxi then you’re all set and you can instruct OpenFirmware to boot from the USB drive : boot usb0/disk@1:3,\System\Library\CoreServices\BootX
  • Hit enter and you should be booting from the USB drive. You can then install MacOSX as you would with a DVD.

booting Linux off USB drive

Here is the copy of the procedure found on the web

Download the official Debian Squeeze netinstaller iso here (around 240 Mb). You can also opt for the smaller businesscard iso (around 70 Mb). If prefer the business card iso as it faster to copy onto a USB stick. Both installation methods require a working internet connection, preferably a wired connection. If you don't have a working internet connection you cannot install MintPPC as the MintPPC specific packages are downloaded over the internet. If you are running a Classic MacOS partition you should read the Release Notes. In Gparted make the USB stick empty. Find also out here what the device name is for your stick (in my case /dev/sda but it could be different). Then copy the content of the iso to the stick. It's important to do this from a PowerPC based Mac as otherwise the dd process goes too fast and your PPC based Mac won't be able to boot from it:

sudo dd if=/path/to/mini.iso of=/dev/sda

To do the same in OSX, do the following. First convert the .iso file to an .img file in OSX so that it can be written to a USB stick:

hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/mini.iso

There is a bug in the "hdiutil" command. No matter what you call the target, it will add .dmg to the end. You can either ignore that or delete the .dmg extension.

To download the images which were already converted to be burnt to USB immediately:
http://dl.dropbox.com/u/3809776/mini.img
http://dl.dropbox.com/u/3809776/debian-6.0.3-powerpc-businesscard.img
http://dl.dropbox.com/u/3809776/mintppc93imgmd5sums.txt

To create the bootable USB stick, you need to get the disk number which is easiest to do using Disk Utility, select your USB stick and use the "Info" button. Then 'burn it':

sudo dd if=/path/to/mini.imgcreatedabove of=/dev/rdiskN bs=1m
("N" is the number of the USB disk obtained from Disk Utility)

More info on creating bootable USB drives from OSX can be found here.

Then boot from the USB if your Mac is capable of doing this. One of my Pismo is, the other not, don't ask me why. They are both the same.

Boot in open firmware by holding option+command+o+f. Then find out which is the device:

dev / ls
You should see somewhere usb with an extra entry disk, write that number down usb19 or something in my case. Then have a look at the devalias:

devalias
Now it's either usb0 or usb1 which is associated with usb19. This is your boot device, in my case usb1. Then boot:

boot usb1/disk@1:2,\\yaboot (or)
boot usb0/disk@1:2,\\yaboot

reset the password

  • open the machine and change the total amount of RAM
  • reset the PRAM by using Option-Command-P-R at boot time

check CPU speed

  • launch Open Firmware
  • dev /cpus/PowerPC,G4@0
  • .propertiies
  • search for cpu-frequency

Darwin

boot

  • Open Firmware loads and runs /System/Library/CoreServices/BootX
  • BootX loads kernel and essential device drivers
  • kernel loads all device drivers for the devices connected to the computer
  • kernel determines the drive it was loaded from by consulting Open Firmware and mounts the boot drive at system root (/)
  • kernel starts internal process server and launchd daemon

launchd

  • scans through /System/Library/LaunchDaemons and /Library/LaunchDaemons
  • uses XML-formatted property list (plist) to store configuration information for each daemon
  • handles also agents - starts them when user logs in, stops when user logs out (/System/Library/LaunchAgents and /Library/LaunchAgents)
  • some of the custom daemons still use SystemStarter (/System/Library/StartupItems and /Library/StartupItems
  • launchctl list - all user daemon / agents
  • sudo launchctl list - all active system services
  • launchctl can also start/stop services

/etc/hostconfig

  • set of name-value pairs indicating which services should be run and which ones should not
  • SystemStarter starts the service, then the service use the information from the file to decide whether to run or not

startup items

  • create a directory in /Library/StartupItems
  • create executable in that directory (could be a shell script)
  • the name of the executable should match the name of the directory
  • create _StartupParameters.plist_ file in the directory, ex:
{
  Description     = "local disks";
  Provides        = ("Disks");
  Requires        = ("SecurityServer");
  Uses            = ("System Tuning");
  OrderPreference = "None"
}
  • SystemStarter runs only the first startup item it finds for any service provided
  • SystemStarter can also restart or stop startup items by passing the argument (start, restart, stop) to a startup item's executable
  • template startup item:
#!/bin/sh

. /etc/rc/common

StartService()
{
    # insert code to start service here
}
RestartService()
{
    # insert code to restart service here
}
StopService()
{
    # insert code to stop service here
}

RunService "$1"
  • sudo SystemStarter _action_ _service_, ex: sudo SystemStarter stop Disks

booting into safe mode

  • hold down the Shift key while booting, OS will load only the absolute minimum of kernel extensions and only most crucial daemons and services

logging in

  • loginwindow displays login screen
  • after log in your environment is loaded
  • SystemUIServer is launched and handles the menu bar and menu extras (those little applets in the upper-right area of the screen)
  • pasteboard server (pbs) is launched
  • mouse, keyboard, sound and display are configured according to your preferences
  • user-defined login items are processed
  • Dock and Finder are started
  • to bypass the GUI login window enter >console as your username (if you have just the list of users press Option-Shift-Down Arrow and then press Return)
  • after a user has logged in, the loginwindow process:
    • monitors Finder and Dock and restarts them if thay unexpectedly exit
    • displays alert dialogs from hidden apps
    • manages the Force Quit window (Option-Command-Esc)
    • manages the logout process
  • if loginwindow process dies, launchd restarts it

logging out and shutting down the system

  • log out
    • all programs started while logged in quit automatically
  • shut down
    • all running startup items are called with stop parameter
    • all running processes are stopped
    • filesystem is synchronized with in-memory caches
    • the system hands off control to OpenFirmware
    • OpenFirmware either shuts down the system or reboots
  • sudo reboot
  • sudo shutdown -h now

fink

  • /sw/bin/fink list - what packages are available
  • sudo /sw/bin/fink install _packagename_
  • sudo /sw/bin/fink remove _packagename_
  • sudo /sw/bin/fink selfupdate - before updating; to synchronize fink with its selfupdate option (stick to point releases for stability)
  • sudo /sw/bin/fink update _packagename_
  • sudo /sw/bin/fink update-all

Terminal

  • export CLICOLOR=YES - to enable color output for _ls_; to customize set _LSCOLORS_ variable (see man ls)
  • to launch another Terminal use File->New Shell

enabling the root user

  • start NetInfo Manager
  • click the padlock to authenticate yourself
  • select Security->Enable Root User
  • or using command-line: sudo passwd root

command line

Spotlight database

  • mdfind -onlyin /Users/loginname "kMDItemAcquisitionMake == 'Canon'"

sticky bit

When the sticky bit is set on directory then a user can delete only files in the directory that belong to him, even if he has access rights to the directory because of a group membership.

ACLs

  • by default ACLs are not enabled on the client version of MacOS X; to enable ACLs on the boot volume use: sudo /usr/sbin/fsaclctl -p / -e
  • to view Access Control Entries: ls -le
  • to add ACE to a file use: chmod +a "user access permission", where access = allow or deny and permission = read, write or delete
  • to remove ACE: chmod -a "user access permission"
  • to add (or remove) specific entry in ACL use: chmod +a# positionInACL …

BSD flags

  • ls -lo
  • system flags:
    • sappnd - append only
    • schg - unmodifiable
  • user flags:
    • uappnd
    • uchg
  • to set flag: chflags uappnd fileName
  • to remove flag chflags nouappnd,nouchg fileName

HFS+ attributes

  • Commonly used
    • A - the file is an alias
    • C - the file/folder has a custom icon
    • E - the file's/folder's extension is hidden
    • L - the file is locked
    • V - the file/folder is invisible
  • to get the attributes use: /Developer/Tools/GetFileInfo fileName
    • attributes that are capitalized are in effect
  • to set the attribute use a capital letter, to remove use a lowercase letter
    • ex: /Developer/Tools/SetFile -a V fileName

diskutil

  • diskutil list
  • diskutil info [diskID | mountpoint]
  • diskutil verifyPermissions [diskID | mountpoint]
  • diskutil repairPermissions [diskID | mountpoint]
  • diskutil verifyDisk [diskID | mountpoint]
  • diskutil repairDisk [diskID | mountpoint]
    • to verify/repair disk should be unmounted, in case you want to verify/repair the disk you booted from:
      • boot off MacOS X install DVD and select Installer -> Open Disk Utility
      • boot the machine in the FireWire target disk mode by holding down the T key
      • boot into single-user mode and then run: /sbin/fsck -fy /
  • diskutil eraseDisk [filesystem] newName [diskID | mountpoint]
  • diskutil zeroDisk [diskID | mountpoint]
  • diskutil randomDisk [numberOfPasses] [diskID | mountpoint]
  • diskutil createRAID [stripe|mirror] raidName filesystem diskIDs…

hdiutil

  • hdiutil mount imagename - by default mounts into the /Volumes folder
  • hdiutil mount -mountpoint directory imagename - the directory has to exist
  • hdiutil unmount mountpoint
  • to create a new disk image
    • go to Disk Utility -> File -> New -> Blank Disk Image
    • hdiutil create [-encryption] -volname volumename -fs filesystem -size size imagename
        • for detailed options description see hdiutil create -help
  • to create a disk image that holds the content of a folder
    • go to Disk Utility -> File -> New -> Disk Image From Folder
    • hdiutil create -srcfolder folder -format UDIF imagename - UDIF means read/write disk image, the default is read-only
  • to create a disk image from a device
    • go to Disk Utility -> File -> New -> Disk Image From (Select a Device)
    • ex: sudo hdiutil convert /dev/disk1 -format UDZO -o /FirewireBackup.dmg
  • to convert disk image (for example to read-only format)
    • go to Disk Utility -> Images -> Convert
    • hdiutil convert -format format -o outputfile imagefile
  • to burn an image to CD/DVD
    • go to Disk Utility -> Images -> Burn
    • hdiutil burn Documents.dmg
  • to restore a disk image to a drive
    • go to Disk Utility -> Restore panel
      • it's possible to restore contents of one drive to another drive that is either larger or smaller(if there is enough space to hold the data) than the original drive

Printing

  • MacOS X uses CUPS, you manage it also via http://localhost:631
  • list of printers attached: lpstat -a
  • show default printer: lpstat -d
  • set default printer: lpoptions -d printerName
  • to create a desktop printer go to Printer Setup Utility -> Printers -> Create Desktop Printer
  • lp filename - works for any plain text/PDF/PostScript file
  • to print on a selected printer: lp -d printerQueue filename
  • pstopdf file.ps - converts from PostScript to PDF
  • enscript -p file.ps file.txt - converts from plaint-text to PostScript

Networking

  • Any changes made using ifconfig are not reflected in the Network preference panel
  • Any changes in /etc/resolv.conf will be lost next time you use Network preference panel

Monitoring the system

  • system_profiler
  • system_profiler -listDataTypes
  • system_profiler system_profiler SPHardwareDataType
  • to view the logs use tail, grep or simply Utilities -> Console
  • lsof -f processname
  • lsof -u username
  • lsof -i - to see open network connections
  • who
  • w
  • last - who has been logged into the system
  • ps -x - all processess that belong to a user
  • ps -aux - all processes running on the system
  • top
  • to Force Quit use Option+Command+Escape
  • kill procesID
  • killall processName - to kill not only the parent process but also all the child processes
  • VNC server build-in, go to System Preferences -> Sharing panel and select Apple Remote Desktop
  • free alternative - Vine VNC Server
  • a popular VNC client is Chicken of the VNC
  • to enable Secure Shell server go to System Preferences -> Sharing panel and select Remote Login
  • to connect to ssh server select File -> Connect to Server in the Terminal

Preferences and defaults

  • property lists are stored in binary or XML format
  • property lists are located in /Library/Preferences or ~Library/Preferences
  • ByHost subdir contains host-based settings
  • ~Library/Preferences/.GlobalPreferences.plist - preferences used by all apps
  • to read/write preferences use:
    • /Developer/Applications/Utilities/Property List Editor
    • defaults - command-line tool (make sure the app is not running when you change its preferences)
      • defaults read domain [key], ex: defaults read com.apple.finder
      • defaults read -app appName, ex: defaults read -app Mail
      • defaults write domain key value, ex: defaults write com.apple.terminal BlinkCursor YES
      • defaults write domain key -array element1 element2 element3… - replace values
      • defaults write domain key -array-add element1 element2 element3… - append values
      • defaults -currentHost read domain - read host-specific preferences
      • defaults read -g - read global preferences
  • to determine preference keys
    • search the web
    • defaults find Opaque - searching for a string in the defaults database
    • strings pathToBinaryFile - examining binary file for preference keys
  • to convert from one to the other use:
    • plutil -convert xml1 com.company.app.plist
    • plutil -convert binary1 com.company.app.plist
  • to check the syntax use: plutil -lint com.company.app.plist

Open Directory

  • local domain:
    • local NetInfo db in /var/db/netinfo
    • local Shadow Pasword db in /var/db/shadow
    • Bonjour, SLP and SMB for discovery of shared filesystems and other network services
  • GUI based /Applications/Utilities/NetInfo Manager
  • command-line access to Open Directory on the local system: dscl .
  • command-line access to NetInfo database: nicl .
  • For shared domains use /Applications/Utilities/Directory Access (connect to Active Directory!)

Aqua

Finder

  • to see all the files in Finder execute following command in the Terminal: defaults write com.apple.Finder AppleShowAllFiles YES

File sharing

  • Sharing to Mac clients: enable Personal File Sharing in the Sharing preference panel
  • Sharing to Windows clients
    • enable Windows Sharing checkbox in the Sharing preference panel
    • change SMB workgroup using /Applications/Utilities/Directory Access

Changing the name of the machine

  • To change the name of the machine go to Sharing preference panel

Networking

  • To set up VPN connection launch Applications->Internet Connect->VPN
  • To turn on/off the firewall go to System Preferences->Sharing->Firewall
  • To share internet connection go to System Preferences->Sharing->Internet

AppleScript

  • a logical place to store user scripts is ~/Library/Scripts
  • to enable Script menu run Applications -> AppleScript -> AppleScript Utility and enable "Show Script Menu in the menu bar" option
  • to create a new script use Applications -> AppleScript -> Script Editor
    • - line comment, (**) - block comment
    • to find application dictionary go to File -> Open Dictionary
  • to use AppleScript from the command-line use osascript -e

Automator

  • use Automator scripts as a plug-in for Folder Actions

X11

  • to enable full screen mode go to X11->Preferences->Output
  • to hide X11 and return to Aqua press Option-Command-A
  • to use alternative window manager:
    • cp /etc/X11/xinit/xinitrc $HOME/.xinitrc
    • update the last line to use your favourite window manager ex: exec wmaker
  • to access contextual menu by clicking an xterm window use Control-click, Control-Option-click or Control-Command-click

10.6 Snow Leopard

Aqua

  • to change log-in image replace System/Library/CoreServices/DefaultDesktop.jpg with image of your choice

FileVault

  • to unlock an account try this or this, here is the local copy:

If you have not repaired permissions, I highly recommend you do so, because that is what caused the problem. Weirdly enough, another Mac that I was close to encountering the same problem with took the old password instead of the new one.
This may sound really weird and simple, but if you did not repair your permissions first, try your old password. I'm also aware to set up FileVault in the first place, you need to set a Master Password. Did you try that? Or did you lock yourself out of both?
Try logging into your account with the old and the new password. Then, if all else fails, relay to the master password—the old and new as well.

$ ssh administrator@the_host_name_of_the_computer_you_want_to_reach
enter the administrator password to logon
$ sudo security unlock-keychain /Library/Keychains/FileVaultMaster.keychain
enter the password to unlock FileVault masterkeychain
sudo hdiutil chpass /Users/.username/username.sparsebundle -recover/Library/Keychains/FileVaultMaster.keychain -newstdinpass
enter new password twice, type carefully
$ reboot

British Key­board Layout

Here is the original page, local copy follows: download the file, move unzipped files to the /Library/Keyboard Layouts folder, log off and log on again, select the mapping from System Preferences->Language & Text.

O ile nie zaznaczono inaczej, treść tej strony objęta jest licencją Creative Commons Attribution-Share Alike 2.5 License.