Random tidbits, some pasted from other pages.
Updates for 10.3
The Finder is finally using more of com.apple.finder, so this now
works:
defaults write com.apple.finder NSUserKeyEquivalents '{"by Name"="@4";}'
defaults write com.apple.finder NSUserKeyEquivalents '{"Clean Up"="@5";}'
Yay for me, a hotkey for Arrange By Name. If you want both you have to do
both on one line or edit com.apple.finder.plist by hand. There's also
Clean Up Selection, which happens if you have something selected. (Clean Up
would become option-cmd-5 if you do). If you put in both on the same
key, it will just change the text and cmd-5 will do whichever is appropriate.
So, I have, in com.apple.finder.plist:
<key>NSUserKeyEquivalents</key>
<dict>
<key>by Name</key>
<string>@4</string>
<key>Clean Up</key>
<string>@5</string>
<key>Clean Up Selection</key>
<string>@5</string>
</dict>
See the XDarwin section, below, for getting X working (with good
copy/paste, too).
Terminal supports FocusFollowsMouse:
defaults write com.apple.Terminal FocusFollowsMouse -string YES
Startup
- Holding down the option key will produce a volume
list, allowing the user to select which system to start from. This is a
hardware-based feature, and may not be available on all systems.
- Holding
down the command and v keys will put the system into "verbose" mode,
such that you can watch the status of the system as all of the drivers
and packages load.
- Holding down the command and s
keys will put the system into "single-user" mode, and put you right into
a shell. This should only be used in extreme troubleshooting situations
and only if you're comfortable with shell-level system administration.
- Use ">console" as the login to get a BSD console login prompt
- SystemStarter
- how to add things to the UNIX boot process (see the SSH example if
you enabled it from System Preferences)
- comand-OF @ boot to get open boot prom.
Also, nvram -p to print contents of nvram.
sysctl to tweak various system params
tweak /etc/ttys to get no aqua
- Other keys to hold down: X - start X instead of OS9; Shift - disable
Login Items
-
More Keys
Compiling
- You do not technically need a GCC compiler. MacOSX comes with a modified version
of GCC which Apple has renamed to "CC". This compiler is customized for OSX's
file structure. Some configures might not work directly with the OSX compiler,
however. Top get around this, modify or create an "/etc/make.conf" file with
"CFLAGS=-traditional-cpp" in it. This saves having to put it in each Makefile.
If the Makefile isn't working, try adding it to CFLAGS manually
- For programs that use configure that haven't been updated, especially
if they report "unknown system type", try copying /usr/libexec/config.*
to the program source directory - this has config.guess and config.sub supplied
by Apple/darwin so they are known to work.
UNIX OS Configuration
- Hostnames: Two different ways are suggested: "hostname -s " and editing
/etc/hostconfig. Editing /etc/hostconfig seemed to work for me,
by setting HOSTNAME and APPLETALK_HOSTNAME to the desired hostname.
Also, in Preferences->Sharing, set the Computer Name
(otherwise the appletalk name will keep getting reset)
General tips and tricks (mostly UI)
- Copying files with resource forks, Way 1. Source is file "s"
GetFileInfo s (note type, creator, and attribs)
cp s t
cp s/rsrc t.rsrc
RezWack -d t -r t.rsrc -o t.combined
scp t.combined otherbox:
UnRezWack t.combined -o t
mv t.data t
cp t.qtr t/rsrc
example: SetFile -t APPL -c VIS3 -a avBstClInMed t
That way is very scary to me because of the "s/rsrc" line - what the heck
is that? Seems like a sneaky way of getting at the resource fork.
Unfortunately, it doesn't contain the creator/type/etc codes so you
have to set those yourself.
Maybe easier is Way 2. This will include tar/ssh/untar example.
SplitForks s (creates ._s)
tar -cf - s ._s | ssh otherhost '(cd ~/targetdir ; tar -xvf -)'
-on otherhost:
/System/Library/CoreServices/FixupResourceForks ~/targetdir
(will remove ._t after combining it into t)
The use of RezWack/UnRezWack is optional in either case, just presented for
getting two files across the network without tar, and because they are
neat.
Either way will likely need Developer
Tools installed, as SplitForks, GetFileInfo and SetFile are all in
/Developer/Tools (as are the Wack programs)
Warning, FixupResourceForks is a recursive program, it operates on
directories, not files. Try it without arguments, but not as root:
'Error processing "/" (Permission denied)'
So, it sounds like using SplitForks in general will help you do
backups/copies/rsyncs/whatever, as long as you can do the Fixup on
the target system before you need to use the files.
If you look at the ._s file from Way 2 and the t.rsrc from Way 1 with
something like cat -v, you can see they are very similar except that
the ._s file has the FileInfo in it (creator, type, etc.) FixupResourceForks
seems to take a -nosetinfo flag if you don't want it to incorporate those.
It also takes -quiet to not list as it finds them, and -nodelete to preserve
the ._file.
Final note: There's got to be an easier way to do this.
- open command: command line /usr/bin/open will open an file as if you
double clicked it. You can 'open' a file to start the appropriate
application, or even open a directory (even . or ~) to bring up
a Finder window. Handy.
- I really like the haxies
FruitMenu and WindowShade
- System Pref -> Software Update - get free OS upgrades from Apple. This
is very good for improving OSX, really. You may want to wait a while
after a new update is released to see if people report problems,
especially with your particular hardware. Be careful because rolling
an update back is a pain - I think you have to get the old patch
from Apple somehow
- Hiding: Most apps should support Command-H to hide themselves, and Command-M
to minimize (unless you set the windowShade haxie to do something else,
such as windowshade on Command-M). In addition, or if that isn't
working, if you Option-Click on any part of an application, (including the
dock icon) it will hide the current app and bring that one to the front.
- The Dock:
- Dock Location -
Try using the Dock on the right-hand side of the screen. It may seem
wierd at first, but since you read/work left to right, and you try
to use as much screen real estate as possible, and especially on
the nice, wide TiBook screens, you actually have more room on the
right-hand side of the desktop. I can run my webbrowser windows
fully top-to-bottom and not worry about the silly dock getting
covered.
- Dock Aliases folder - I've gotten used to the Windows world a bit for
starting applications from the Startbar, but taking the concept
one further - create a folder in your home directory (I called mine
Dock) and then drop in on the dock, and when you want to add stuff
to your Dock you can have a nice organized just-the-applications-I-use
menu. No need to delete or move applications on disk, just use
aliases. (This is basically what the Windows Start Menu does anyway,
with the added feature that you can put aliases to folders here
and they will auto-expand in the real location)
- Keep In Dock - I like using the dock for my really frequently
used applications for two reasons: one, a single click gets
the application going; two, possibly more important, my
frequently used applications are always in the same place
(at least relative to each other) for task-switching via
mouse or Cmd-Tab. Control or Right clicking a running app
will easily freeze that guy where you want to keep him, then
drag him around as desired.
- Bouncing icons -
Why do the applications bounce on startup? Because MacOSX
is slow, that's why. I know that seems backward, why have
a bounce (which uses more CPU, right?) if it's already slow?
The bouncing is there to indicate that the machine has in
fact gotten your request to start that app up, please wait.
Better than turning the cursor into some lame hourglass, eh?
Well, if you disagree, go ahead and disable it in the Dock
Prefs. If you don't want bouncing icons at all (or you want
them to do something else when they want your attention), try
the Dock Detox
haxie.
- OSX-specific Command line commands -
- open - opens files like double clicking
- chflags - lock and unlock flags
- hdiutil - manipulate drives (including burning)
- disktool - talk to the finder/autodiskmount I think about mounting
and unmounting and other stuff for disks (run with no args for usage),
- diskutil - enableJournal here
- /Developer/Tools/* - wierd stuff, mostly dev oriented, but admins
might find handy (like SetFile and GetFileInfo)
- bless - manipulate boot folders by partition (try bless -info /)
- kmodstat/kmodload/kmodunload - manipulate kernel extensions/modules
- defaults - access the Mac OS X user defaults system
- sc_usage, fs_usage - monitor syscall/filesys usage on procs
- latency - scary looking command to play with sched/interupts
- AppleFileServer - not sure how to call this
- AppleSystemProfiler - cmd line system info dmp
- DirectoryService - don't know
- Print - lpr replacement?
- pdisk - manage apple partitions?
- pbxbuild - build Project Builder projects
- otool -L - close to ldd - man dyld
- fstat - file status (like fuser)
- sample - external process profiler
- asr - Apple Software Restore (disk image/cloner)
- pmset - change power settings (disk spindown time, etc.)
- OSX-specific flags to normal command line commands -
- ls -lo - show the flags from lock/unlock (chflags)
- OSX-specific daemons -
- autodiskmount - mounts harddrives and removable media
- lookupd - in charge of passwd, groups, hosts, etc. lookups
- Finder.app - go ahead and HUP it if you want
- OSX-included nifty unix commands -
- jot
- rs
- xev - (part of xfree86) get keyboard events for mapping Xdefaults
- rsync - (even better if you fink update to 2.4.6) - you can do things like:
rsync -v --rsh=ssh foo.dmg hostname.company.com: --bwlimit=30 --progress
- lsof - list open file handles (great for disk-busy messages when ejecting)
- fixing up tcsh -
In particular, I put "unset recexact" in my .tcshrc, because the
osx default appears to set it, and that means that exact matches
will move on when you hit tab instead of showing a list. - try it
with "co" when you want to type something like "compress"
"unset recexact" makes "co" act like "co".
- Screensaver -
I'd like a better screen saver, but combining UNIX crontab with
the SlideShow screensaver, you can write a small script to download,
say, the Astronomy Picture of the Day
every morning and add it to your screensaver pics. This is also
a way to change your desktop at "random" but that's up to you to
figure out (probably requires Applescript or more hunting)
Update: Under 10.1, the applescript magic you need is something like:
tell application "Finder"
try
set the desktop picture to file imagePath
end try
end tell
Update: OSX 10.2 makes nice updates to the randomness of both
Slideshow and desktop picture.
- Keyboard and the UI -
I recommend, under Prefs -> Keyboard -> Full Keyboard Access, that
you use the Control-plus-Function keys to get around more quickly:
Control-F2 to get to the menu bar and Control-F3 to get to the dock.
Between that, Cmd-Tab to switch running apps, and various application
window-navigation keys, you can get from place to place and window to
window fairly quickly.
- Preferences -
Preferences are kept in .plist files - and here's the best parts: they
are all xml, and you get to keep them in your homedir, so they are
customized for you, and more importantly, you can edit them. There
are some things that are in the xml files that you can't edit via the
normal UI, so look around - for example, if you look in your homedir
for Library/Preferences/com.apple.Terminal.plist, search for the
string TerminalOpaqueness, and set the real on the next line to .8
or .9, and try to load a new terminal window - voila, it's partially
transparent. And you didn't even have to restart Terminal.
- Terminal -
In addition to being able to set the Opaqueness (above, Preferences)
you can set a window in a .term (with one window or several) to
open with a particular command by setting ExecutionString, for
instance:
<key>ExecutionString</key>
<string>resize ; /usr/local/bin/ssh pegasus -l ekim</string>
Also, I keep my .term files in a folder Terminals under the default
~/Library/Application Support folder.
- Replacing Icons -
This couldn't be easier, even if it is not obvious - if you want
to change an icon for a program/file/whatever, use Get Info (cmd-i)
on something that already has the icon you want, then Edit->Copy. Get
Info on the thing you want to change, Edit->Paste. Done. Cmd-C
and Cmd-V if that's too hard :) Want more icons?
iconfactory
- Show In Finder / Reveal Location -
Don't underestimate the power of letting the Mac tell you where the
thing you are looking at really lives. In addition to the obvious
"ok now that I see it in the UI where is it so I can play with it?",
you can find locations and nose around where other interesting
things might be hiding. "What version of Opera is this in the
Dock?" is easily answered this way, if you don't want to start it
up, for instance.
- Finder Column View -
This is the new mode of the Finder where you can see folders back
and forth as you navigate (it's the right-most view to click on,
looks like 3 columns) - it's very fast to move up and down folders,
especially if you're a keyboard addict like me, and you get all
kinds of handy preview info - applications often have the version
number exposed there (it's magic!), web pages (sometimes?) render,
anything quicktime can read will be playable (movies, audio files)
right there in the Finder window, text files will (often?) be opened.
I'm not sure why some things work and some don't, but when it does,
it's pretty handy. Maybe I'll experiment with this more. If
you get used to this view, and use it all the time, you can even
get along without the "Back", "Path", and "View" buttons in the
Finder windows, so you can free up some screen real estate (you
can still change the view in the "View" menu if you ditch the
toolbar entirely)
Don't forget that the alpha keys will skip you down to that letter
in big folders.
- Finder Toolbar -
Turn it off, view icons or text only, whatever you like. The most
compact you can stand is probably best from a clutter standpoints, so
I'll mention that text-only saves space vertically but not horizontally,
if that is your concern, try icon-only. Looks better, too. If you
drag stuff to the Trash a lot, well you should probably learn to
right click you wacko Mac user you, but in the meantime, open the
Trash from the dock and drag the proxy icon to the tool bar.
(the proxy icon is the icon next to the word Trash in the title bar
of the Trash window)
- ssh server access -
I recommend this only if you know what you are doing, and even
then only behind a firewall. And you have to keep your ssh
installation up-to-date, even if it means using fink or a package
manager if you can't compile it yourself. All that being said,
enabling sshd (and the sftp subsystem, which is handy too) is
as easy as Prefs -> Sharing -> Application -> Allow Remote Login.
That's it. The first time you do this, you'll note a delay, that's
your Mac generationg the openssh public/private keys it needs, even
though you aren't told this is what it is doing. Run top or ps and
watch if you want. Oh and for the love of all that is holy and good
don't run any of the other sharing things without understanding them,
they're all just security holes waiting to be opened. Well, maybe the
web sharing (apache) isn't too bad, but still, don't run it if you
don't need it.
- Playing with disk-like devices -
Backups in particular are currently harder than they should be.
See OReilly
for some interesting workarounds, plus they key you into the hdid and
hdiutil commands. I can use "hdiutil eject -verbose disk1" to
unmount and cleanly remove my Sony Memory Sticks.
- Copying a CD -
The Finder is great for making CDs from your data (just put a blank
recordable media in and it will format some space for you, mount it,
you drag everything just like you want it, and burn) but if you want
to duplicate a CD (for archival purposes, of course), you can try to
use Disk Copy to make a CD/DVD Master disk image (.cdr) and then
burn that to recordable media.
- Console.app and CPU Monitor -
Just two recommendations: Run the Console app and watch your console.
If any (non-commandline) application prints to stdout (via, say, NSLog()),
this is the only place you'll see it. You could see many things that can
help you figure out why your system is behaving strangely. The CPU Monitor
has a nice feature to replace the Dock icon with a live CPU graph. I'd like
to have more control over it (longer time windows, maybe - currently the whole
graph is maybe 30-60 seconds?), or maybe even write other apps that play
with their dock icons, since that's a powerful feature.
- Backup your Stickies -
Where are your stickies stored? In ~/Library/.StickiesDatabase. Not an
XML file, I might add. Looks like a cocoa data dump, actually. If I write
an application that reads them, I'll let you know, but that's what Stickies.app
is for, right?
- Change some hotkeys around -
defaults write com.apple.Terminal NSUserKeyEquivalents '{"Hide Others"="@`";}'
defaults write com.apple.Terminal NSUserKeyEquivalents '{"Quit Terminal"="@$q";}'
Will set the Terminal to have "command-`" as the Hide Others hotkey. You can see
the result in the terminal preferences file after running this. See MacOSX Missing
Manual, page 422, Redefining Keystrokes. Only works with Cocoa apps - so not with the
Finder.
See macosxhints for
a way around that.
- $ = shift
- ^ = control
- ~ = option
- @ = command
- iTools/iDisk -
X11 / XFree86 / XDarwin
update for panther/10.3: the "XDarwin" project at
xdarwin.org or
the xonx project
has become somewhat different. You can pay to get a CD or download
their installer, but frankly, if you want X, you probably know how to
follow directions in a shell. So there's two options.
First, if you are upgrading from a working 10.2 / XDarwin, rumor is that you
can back up /System/Library/Keyboards, and then restore that on the 10.3
install.
Second, and this isn't that hard, you just install it direct from xfree86.org.
xdarwin.org can point you at the exact directory if it changes; this
is the one I used:
binary Xfree86
xdarwin.org can email you directions ... or you can just download the Install
file.
In summary:
Make a new directory to download everything to - there's several files.
First get Xinstall.sh, run that as "sh ./Xinstall.sh -check" and it will verify you are getting the right
files - the result on 10.3.5 was "Darwin-ppc-7.x". Then get, at a minimum: Xbin XDoc Xetc Xfenc Xfnts Xlib Xman
Xquartz Xxserv extract
Now get a root shell in that directory, so that we can make sure the umask
is ok - run umask 022. Then "sh ./Xinstall.sh" and it will go off. It
installs to /etc/X11, /usr/X11R6, and /Applications/XDarwin. That's it,
you're ready to go.
One thing I did change was the definition of the color blue. For whatever
reason, this seems to have changed in xfree86 4.4. (see
/usr/X11R6/lib/X11/doc/RELNOTES and man.txt, search for color4) I put this in
my .Xdefaults and it went back to the "old" color: XTerm*color4: blue
I can't blame the xdarwin.org folks for wanting some compensation, but in
my opinion all they are really providing for the cash is a packaged installer
and the bandwidth. I don't know all the history, it might seem that their actual
work is what xfree86.org is distributing as XDarwin.app? Don't know.
Old info:
As of XFree86 4.2.0 and XDarwin 1.1, XDarwin
supports a real installer for MacOSX. (It's huge but worth it). I run X in
rootless mode, with the following .xinitrc: (updated for 10.3, -cpp option to
xrdb is now needed, or symlink /usr/bin/cpp3 -> /usr/bin/cpp)
#!/bin/sh
exec < $HOME/.xlog 2<&1
echo "`hostname` $DISPLAY `date`"
set -x
xrdb -cpp /usr/bin/cpp -load $HOME/.Xdefaults
xset -b
xset m 100/20
xmodmap -e "keycode 66 = Alt_L"
# fvwm2 installed via fink
/sw/bin/fvwm2 &
xterm -g 80x3+1+1077 -fn 8x13 -n Console -C -T Console
Note that MacOSX hotkeys (like Command-H to hide XDarwin) will only work if
the mouse is in the XDarwin menu bar. Also, Services still don't work.
Things that might be handy:
- xmodmap -e "keycode 66 = Alt_L" - put in your .xinitrc to have the option key be alt
- xterm*VT100.Translations: #override\n\
MetaV : insert-selection(PRIMARY,CUT_BUFFER0)\n\
- put in .Xdefaults (assuming your .xinitrc does xrdb -load $HOME/.Xdefaults)
so that command-V pastes
NetInfo and Lookupd
NetInfo and Lookupd are strange. Let's look at how to play with hosts
lookups. Lookupd handles all hostname (gethostbyname, etc) lookups, and by
default it uses the following search order: CacheAgent, DNSAgent, NIAgent.
NIAgent is NetInfo. Notably missing here is any kind of file lookup.
We'll get to that in a bit.
There's three things I'd like to be able to do: Add a host entry, change
the lookup order, and read from /etc/hosts. The first is a simple workaround
for adding hosts that don't DNS. If that's all you need, it's pretty easy.
We'll start with some basic netinfo management commands. If you want
to do this all via NetInfo Manager, go right ahead, that's probably just
as easy.
Examples: Reading from netinfo: nidump and nicl
{~}(11:24)[186] nicl / -list /
1 users
7 groups
31 networks
33 protocols
48 rpcs
77 services
141 aliases
150 mounts
151 printers
152 localconfig
156 config
27 machines
{~}(11:24)[187] nicl / -list /machines
28 phoenix
29 broadcasthost
30 -DHCP-
In this example, the first / is the "netinfo domain", where / is the root
of the local machine. /machines is the host entries.
{~}(11:25)[193] nidump hosts /
127.0.0.1 phoenix
255.255.255.255 broadcasthost
255.255.255.255 -DHCP-
{~}(11:25)[194] nidump -r /machines /
{
"name" = ( "machines" );
CHILDREN = (
{
"ip_address" = ( "127.0.0.1" );
"name" = ( "phoenix" );
},
{
"ip_address" = ( "255.255.255.255" );
"name" = ( "broadcasthost" );
},
{
"ip_address" = ( "255.255.255.255" );
"name" = ( "-DHCP-" );
}
)
}
Two more ways to get the info, depending what you want to do with it.
The first one is great for reading into niload if you want to break things.
For instance, you could do:
{~}(11:27)[198] nidump hosts / | tee hosts.save
127.0.0.1 phoenix
255.255.255.255 broadcasthost
255.255.255.255 -DHCP-
{~}(11:27)[199] sudo nicl / -delete /machines
{~}(11:27)[200] nidump hosts /
{~}(11:27)[201] sudo niload hosts / < hosts.save
{~}(11:28)[202] nidump hosts /
127.0.0.1 phoenix
255.255.255.255 broadcasthost
255.255.255.255 -DHCP-
...as an example of blowing away all your hosts entries from netinfo.
Note that the CacheAgent of lookupd probably still has any that you used,
so either run lookupd -flushcache (with mixed results) or run
kill -HUP `cat /var/run/lookupd.pid` to flush those entries out.
Since we also just used niload in the previous example, this is how you
get some static entries into netinfo. Make a file with the hosts you
want, in /etc/hosts format, and load them the same way (niload hosts / <file).
Now the real solutions: changing the lookup order and reading from files.
This is really done at the same time. To start, go read the lookupd man
page, it's good stuff. We can control the lookup order for hosts two
different ways: via netinfo or via files. I wanted to try netinfo to get
in the OSX spirit, but even after trying several things that seemed to match
the lookupd man page, it wouldn't work. So, we'll do files. A start would be
to look at the current config:
{~}(11:34)[226] lookupd -configuration
ConfigSource: default
LookupOrder: CacheAgent NIAgent DSAgent
MaxIdleServers: 16
MaxIdleThreads: 16
MaxThreads: 16
TimeToLive: 43200
Timeout: 30
ValidateCache: YES
ValidationLatency: 15
_config_name: Global Configuration
LookupOrder: CacheAgent DNSAgent NIAgent DSAgent
_config_name: Host Configuration
TimeToLive: 60
ValidateCache: NO
_config_name: Group Configuration
LookupOrder: CacheAgent DNSAgent NIAgent DSAgent
_config_name: Network Configuration
ConnectTimeout: 300
_config_name: NIAgent Configuration
Already we see something we don't know: the DSAgent. It's not in
the man page so who knows what that is, we'll just leave it at the
end like it is.
{~}(12:21)[297] sudo mkdir /etc/lookupd
{~}(12:21)[298] cat hosts
LookupOrder CacheAgent FFAgent NIAgent DNSAgent DSAgent
{~}(12:21)[299] sudo cp hosts /etc/lookupd
{~}(12:21)[300] lookupd -configuration | grep -B1 Host
LookupOrder: CacheAgent DNSAgent NIAgent DSAgent
_config_name: Host Configuration
{~}(12:22)[301] grep manticore /etc/hosts
192.168.168.28 manticore.anybrowser.org manticore
{~}(12:22)[302] ping manticore
PING manticore.anybrowser.org (66.80.62.206): 56 data bytes
^C
--- manticore.anybrowser.org ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
{~}(12:22)[303] sudo kill -HUP `cat /var/run/lookupd.pid`
{~}(12:23)[304] lookupd -configuration | grep -B1 Host
LookupOrder: CacheAgent FFAgent NIAgent DNSAgent DSAgent
_config_name: Host Configuration
{~}(12:23)[305] ping manticore
PING manticore.anybrowser.org (192.168.168.28): 56 data bytes
64 bytes from 192.168.168.28: icmp_seq=0 ttl=254 time=5.944 ms
64 bytes from 192.168.168.28: icmp_seq=1 ttl=254 time=4.52 ms
^C
--- manticore.anybrowser.org ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 4.52/5.231/5.944 ms
Recommended Reading
-
Mac OS X: The Missing Manual - Good info, especially if you are
coming from the MacOS9 world, but great for UNIX folk as well.
- MacAddict Magazine - They're wierd, but they do reviews as well as
hardware and software hints, explanations, tips and tricks.
As of the February 2002 issue, they finally recommend switching to
Mac OS X, so they're on our side now ;) Welcome to the best
operating system on the planet, guys and gals.
- Apple mailing lists - I subscribe to
cocoadev, macosxserveradmin, macgamesdev, projectbuilder, and
applepublicsourceannounce
- Omnigroup mailing lists -
They have archives as well as some good lists.