Managing NetInfo directories from the command line

Let’s say you can’t log into your Mac, but you either have access to its hard drive (e.g. booted into FireWire target mode) or you’ve booted into single-user mode (by holding down Cmd-S, then typing “mount /” to enable read-write). On a normal Unix box you’d be able to edit the passwd and fstab files, but on Mac OS X it’s all stored in the NetInfo directory so my usual command-line tricks don’t work. There have to be some CLI utilites to manage the NetInfo directory, right?

Right. My search first turned up niutil, but that doesn’t work for this – it uses the NetInfo daemon. Single-user mode won’t work since the daemon’s not running, and it won’t work for an external drive because the daemon would be accessing the wrong NetInfo directory. So niutil’s out.

A little more searching discovered niutil’s lesser-known little brother, nicl. This puppy accesses the directory directly, no daemon. By using the command line option -raw /Volumes/External\ Drive/var/db/netinfo/local.nidb (or a variation thereof, if you’re in single-user mode), you can query and modify the NetInfo directory. Hooray.

One last note: from what I’ve seen, you can’t modify keys directly, you need to delete then create them. Kind of silly, and maybe I’m wrong, but that’s what I read.

Some NetInfo CLI examples: resetting an account password, creating a new user, enabling root login.

One Response to “Managing NetInfo directories from the command line”

  1. Danielle Says:
    1

    Hahaha, at least my computer problems contribute to your education =)

Leave a Reply

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: