MacOS X Notes

Some potentially useful info on MacOS-X I've picked up. In no logical order. And built up slowly over time.
  1. To launch (bundled) apps from the command line, use the open command.
    eg
    open /Applications/Calculator.app

  2. Logging in as '>console' with no password switches the GUI off and goes into a nice text only console.
    These also work:
    >console
    >power
    >restart
    >exit

  3. There is a macosx version of VNC available called osxvnc. In case you didn't know, vnc is a free, open-source remote desktop admin tool. Much like Timbuktu (sp?) or what ever it's called. IMO it's faster and better. It also has a groovy factor of 98.
    I got my copy of osxvnc at http://netmath.math.uiuc.edu/vnc/.

    Update:
    There are now loads of VNC server/client options for OS-X, including Chicken of the VNC and VNC Server. Google it:)

  4. To boot MacOSX in verbose mode hold down the command (Apple) key and press V while booting. This will show all the kernel activities during boot time on the screen.
    To boot into single user mode during reboot, hold down the command(apple) key and press S while booting. This will allow read-only access to the system as root, allowing for system checks and other maintence to be performed. Type exit to continue into multi-user mode which is the default for the MacOSX environment.

  5. Lots of macosx binaries here: http://macosx.forked.net/

  6. You can stop netinfo getting involved with authentication and go back to the normal BSD flatfiles (/etc/master.passwd, /etc/hosts etc) by simply creating the file:
    /etc/lookupd/global
    containing:
    LookupOrder FFAgent
    and then HUPping the lookupd process.

    Hey presto, things start behaving like UNIX.

    man lookupd is well worth reading - you can do your lookups with Netinfo, DNS, LDAP and even NIS! All in the man page :)

    lookupd is good, but Apple would prefer you to use their Directory Services API. In fairness, it's very powerful and, from a users point-of-view, much easier to configure. But after delving into the code I realised it was a bit of a monster.

  7. Good Objective-C resources:
    http://www.cs.indiana.edu/classes/c304/oop-intro.html - a really good way to get acquainted with Objective-C from C
    http://www.objc.info/ - an objective-c homepage.

  8. The defaults(1) utility can change system preferences.
    eg defaults write com.apple.loginwindow Finder <path> Will set your finder application to be something other than the finder.

  9. In 10.4 (Tiger) Loginhooks stopped working without warning. Thanks Apple, you bastards. You can enable them in 10.4 using the defaults system by running:
    sudo defaults write com.apple.loginwindow LoginHook </path/to/script>
    sudo defaults write com.apple.loginwindow LogoutHook </path/to/script>
    In versions before 10.4, use the following method:
    /System/Library/CoreServices/loginwindow.app/loginwindow can have several options added to it to hook logins and logouts
    -LoginHook <path>
    -LogoutHook <path>
    Specify a pathname to a script/program to run on a successful login/logout.
    -PowerOffDisabled <value>
    Set this to Yes to disable the 'shutdown' and 'restart' buttons.
    Simply tack these onto the end of the command-line in /etc/ttys, eg
    console "/System/Library/CoreServices/loginwindow.app/loginwindow -PowerOffDisabled YES -LoginHook /scripts/cleanup" vt100 on secure window=/System/Library/CoreServices/WindowServer onoption="/usr/libexec/getty std.9600"

  10. When mapping record attributes to LDAP attributes in the Directory Access configuration application, you can use a hash ('#', also incorrectly referred to as a "pound" in some of the more backwards parts of the world) as the leftmost character to indicate that the value is a literal and not an LDAP attribute. eg Let's say that you want all users to have the same home directory, (useful in a lab environment). You could map the record type: NFSHomeDirectory to #/Users/loginhome Rather than get the users' home directories from LDAP, it will always use /Users/loginhome.

  11. The Directory Service attribute NFSHomeDirectory refers to the directory on the client machine where the user's home directory either is, or should be mounted if it a remote share.

  12. The Directory Service attribute HomeDirectory can be used to refer to a remote share that should be automatically mounted at login as the user's home directory. For a remote AFP share, the entry is in XML and has the following format:
    <homeDir><url>afp://xxx.xxx.xxx.xxx/sharename</url><path>pathfromshare</path></homedir>

    eg if your home directory was in the directory "john" on the share afp://192.168.1.5/Homes, the entry would be:
    <homeDir><url>afp://192.168.1.5/Homes</url><path>john</path></homedir>

    or if you are mounting a Netatalk home directory from the same server, you can leave the path blank:
    <homeDir><url>afp://192.168.1.5/Home-Directory</url><path></path></homedir>

  13. As of 10.3+ this no longer works!
    If an automounted home directory, such as an AFP share, can't be mounted in the user's home directory (as specified by the NFSHomeDirectory attribute) for any reason, it is mounted as /private/Users. This can happen if the mount point is not empty.

    Whilst this is undocumented behaviour, it allows any AFP share to be mounted automatically at login, even if it's not the user's home directory.

  14. We authenticate our OS-X lab machines from an LDAP server (OpenLDAP) and experienced serious problems with the server slowing down during the course of the day, until no-one could login. Restarting the server did not help. Interestingly, a PHP application that uses the same LDAP server for authentication, still managed to authenticate successfully the while the OS-X machines were hanging.

    The only way we managed to get everything working again was to run the Berkeley DB repair utility - which took 15 minutes to run, during which time no-one could login at all. The problem seemed to be BDB holding an ever growing number of open locks, despite access being read-only.

    We managed to avoid the problem by not using Berkeley DB, and instead compiling in good old GDBM. Since then, no problems whatsoever. This probably isn't a great idea if you are frequently performing updates tho'.

  15. Suzanne's Mac Startup Page is superb collection of the various wild and wonderful startup-key combinations available on the Mac. This excellent resource also contains information harvested from various sources (including NetBSD) regarding OpenFirmware. Target mode is very cool btw!

  16. In 10.4 you can disable the resource hog that is Spotlight, by changing the entry in /etc/hostconfig that looks like:
    SPOTLIGHT=-YES-
    to
    SPOTLIGHT=-NO-

    Issuing the following commands will prevent all of the irritating indexing:
    sudo mdutil -i off /
    sudo mdutil -E /

    Turning the indexing off but keeping spotlight running is probably what you want, or rather it's more like the previous behaviour: find works well but you get your CPU back.

  17. Dashboard does indeed suck but by removing the key assignment and poofing the icon, you never have to see it.

    AFAICT the much touted 'defaults' hack that supposedly disables Dashboard does nothing. Don't waste your time!

  18. This also stopped working in 10.4. Thanks again dickheads.
    The security of single-user mode can be increased so that the root password is required to be entered before single-user mode will allow access.
    All you need to do is change 'secure' to 'insecure' on the 'console' line of /etc/ttys

  19. The Dashboard icon in the dock can be 'poof'ed away. To put it back, open:
    /Library/Preferences/com.apple.dock.plist in the Property List Editor and change the value for 'checked-for-dashboard' from true to false. Save the plist file and then restart the Dock:
    killall -1 Dock

    Seemingly, if this is set to false, the Dock checks to see if the Dashboard is present in the "persistent apps" section, and if not, adds it. The Dashboard icon, unlike normal app icons, does not refer to an actual app. Instead, it is represented in the plist file as a tile-type of "dashboard-tile".

Feedback to veg.


<< Back

Valid XHTML 1.0!