Setting up your OS X from scratch
WARNING: The tips and instructions below require a certain amount of UNIX-savvy and geekiness. If you know nothing about UNIX, don't even bother to try most of the hacks below. I cannot stress enough that you need to learn about UNIX first, before venturing into these muddy waters. If you screw up your Mac, don't come whining to me. The hacks are pretty benign, but not if you don't know what "rm -rf /" does.
NOTE:The tips below are still for 10.1 only. To find out which still work for 10.2, please consult my weblog. In due time, I will clean this page up a bit.
Contents
I have been using OS X from the moment it was in beta and have acquired quite a bit of experience dealing with the many intricacies of this multifaceted operating system. In June 2001, I had to do a complete reinstall after a hard drive failure. I grabbed this opportunity (always look at the bright side...) to set up a quick "from OSX to custom geek toy" list. A step-by-step walkthrough is given below. Let me know if some things are missing or if you have suggestions or better solutions.
All the hacks listed apply to MacOS version 10.1 and above.
Honestly, the best way is to keep OS X and OS 9 on different partitions. Why? Well, for starters, these are really two different kinds of operating system. So, as a consequence, it is tidy to keep the file directories separate. Another reason is that you can put disk maintenance stuff on both partitions and occasionally check and repair the other partition.
If you have a spacious disk, you might even consider adding more partitions. At the very least, consider setting aside a reasonable sized partition to hold the swapfile (virtual memory). The following image shows the current partition scheme of my Titanium's 20Gb drive. The names of my partitions are completely arbitrary.

OS X resides on the "XSpace" partition (the name is a tribute to one of Apple's deceased projects).
A much smaller partition, Classic, holds a minimal OS 9 version to be used as classic environment within OS X. I rarely boot in OS9 anymore. So why waste diskspace to it?.
Another small-sized partition, 400Mb, has been created to keep the swapfile(s). This partition is called "STM", for Short Term Memory. You could also store OS 9's Virtual Memory file here. If you have a lot of RAM (say, more than 512), OSX will only use one swapfile of 80Mb. One could question the use of a separate swap partition if one has plenty of RAM. OSX will, however, always create a new single 80Mb swapfile at startup. If that file is on a different small partition, you won't fragment your OS X drive that much. IMHO.
I store all my applications (both Classic and OSX) in a different partition. I just find it neat. There is a bug in Apple's Installer, though. It assumes all applications are kept in the original location. For example, if you move Mail.app to a folder named "Internet", update 10.1 fails to search for the moved file and create a Mail.app folder in the original location with the modified components. It's up to you to copy over the changed files into the old Mail.app. Annoying, indeed.
I devoted one partition solely to the UNIX packages installed with the Fink package manager (see below).
Finally, the rest of the disk space has been set up for the Users folder, since it will really bear the bulk of data files.
The major advantage of the above partition scheme is that you can have the various partitions on removable drives to transport to other machines. It also makes for easy backup, since you would be backing up only the personal files. Yet another good reason, is that with the customizable folders on different partitions, you can easily reinstall OS X if necessary on the OSX partition, while leaving the rest intact.
Just a bit of CD shoving and mouse-clicking. Make sure to install the Developer Tools as well. You can get it from Apple's website, if it was not included with your OS X copy. To get this package, you need to become a member of Apple's Developer Connection. This is, fortunately, free. To do so, go to connect.apple.com and subscribe. Soon you are subscribed, log in to the same page, click on "Download Software", then on "Mac OS X", which will finally enable you to download "Mac OS X Developer Tools".
Go to the Terminal, and type
cmd-prompt: sudo passwd root |
4. Set the host name (optional)
Do this only if you have a static IP address. Setting the hostname can be beneficial in some cases, such as e.g. setting up your Mac as a sendmail SMTP client:
- navigate to /etc
- su to root
- vi hostconfig
- replace "HOSTNAME=-AUTOMATIC-" with e.g. "HOSTNAME=slashdot.org"
- without quotation marks, of course, and make sure the IP name is valid!
Sendmail needs the above modification, but Heliodoro Tammaro suggest a more UNIX way. Just create a fictive hosts file (in the /etc/hosts format, or simply edit /etc/hosts) in this fashion:
#It needs at least 2 fields: the IP and the FQDN; |
Make as many entries as you need. For instance, if you are using the location manager and have a different, but static IP for each location your machine will automatically switch name.
To load the hosts file type "niload hosts . < /path/to/my/hosts-file" as root.
As shown in the partition setup above, a separate partition is dedicated to the OSX's swapfile. To have the Mac actually use that partition, some modifications are required. First, determine the location of the swap partition, and use that to create an /etc/fstab entry:
|
cmd-prompt: df -k Filesystem 1k-blocks Used Available Use% Mounted on /dev/disk0s13 3669660 1922272 1747388 53% / devfs 1 1 0 100% /dev /dev/disk0s9 409528 84628 324900 21% /Volumes/STM /dev/disk0s11 2096928 1057744 1039184 51% /Applications /dev/disk0s14 11373824 1212288 10161536 11% /Users fdesc 1 1 0 100% /dev <volfs> 512 512 0 100% /.vol /dev/disk0s10 409528 260024 149504 64% /Volumes/Classic /dev/disk0s12 1572704 741416 831288 48% /Volumes/GNU cmd-prompt: sudo vi /etc/fstab |
The line to add to /etc/fstab is (this one is modified, Dominique Martel pointed out the obvious... Instead of mounting into /Volumes/STM, we might as well mount into /private/var/vm and save ourselves editing the /etc/rc file!):
|
/dev/disk0s9 /private/var/vm hfs rw 1 2 |
Obviously, the "/dev/disk0s9" entry may be different on your system, just check the output of "df -k".
If you would like to know the difference in performance before and after moving swap files, please check out this article at resexcellence.com.
Caveat emptor. Read this link for a potential risk using the fstab file and a alternative approach. I haven't tun into problems with fstab myself, but noticed something during startup. During reboot or startup, the system checks the drives. This checkup occurs after fstab has been processed. If the system finds problems with a partition, it will unmount it and repair it. This means that the partition is re-mounted into /Volumes. So, if this happens, just do not log in, but instead, reboot again. I start up my Macs in verbose mode (command-V) so I can see right away if the mounts are proper.
6. Move the Users and Applications folders
With credits to Alan Mortensen and Jens Henoch.
I use fstab to mount my Users and Applications partitions into /Users and /Applications, respectively. Previously, I used symbolic links, but found that symbolic links are not recognized by the Installer, which can mess up system upgrades. If you already have stuff in your old Users and Applications folder, use the ditto command to copy them over.
cmd-prompt: su |
The command 'ditto' copies source directories to a destination directory, thereby preserving resource forks, owner, mode, and groups. (thanks to "foamy" from this tip!). Warning: do not forget to pass the parameter -rsrcFork to ditto or you will fail to copy resource forks and hence make quite a few files useless.
Edit the fstab file in /etc to add a line that mounts the Users partition right into /Users. Please check the tip on moving the swapfile for the procedure of creating and editing an fstab file: The following lines should be added, in which the device number can be obtained by issueing the df or mount command:
/dev/disk0s11 /Applications hfs rw 1 2 |
Please note that both the /Users and /Applications folders have to be existent, otherwise the system will not mount the partitions in those mount points. Since both folders are in use while you attempt to move around stuff, it is best to reboot in single user mode (press command-S) during reboot. Follow the instructions that appear at the prompt when you reboot in single user mode, and then:
cd / |
and similarly for Applications. After the next restart, if mounts were done properly, you may wish to remove the old directories. Also, it is a good idea to load fstab into the NetInfo database(in root-mode):
sudo niload -m fstab / < /etc/fstab |
As an added bonus, you can make the Documents folder in your OS 9 folder an alias to your user directory as well. In my case, I have aliased the Documents folder in OS 9 to the Documents folder in my home directory. With this solution, you can keep all your personal stuff in one single parent directory. How clean and tidy!
Alternative option for moving the Users folder
Open the NetInfo Manager application. Select the user to edit from the "users" directory in the main window. In the bottom pane, the property-value pairs for the selected users will be displayed. At the bottom, the property "home" is shown with value "/Users/username". Replace this with "/Volumes/Users/username". This is a decent solution, but quite inefficient if you have more than one user, and gives you two Users directories on the drive.
7. Set up command line printing
This solution has been suggested by Alex Levine and works smoothly. The step-by-step instructions below assume you are root and that your ethernet connected laserprinter is comfortably called "Leezer".
In the file /etc/printcap, create the following entry
Leezer:\
:lp=:rm=Leezer.dot.org:rp=lp:sd=/var/spool/lpd/Leezer:lf=/var/log/Leezer-errs:
god-mode: cd /var/spool/lpd/ |
Finally, go to the Print Center, and add the printer you just created, by selecting "Leezer" from the Directory Services panel. That's it. Now you can do:
cmd-prompt: lpr -PLeezer file.ps |
Note that lpc does not work properly under OSX. Ignore it.
This is horribly easy. Go to www.xfree.org and get the precompiled binaries for Darwin. Download everything and just follow the instructions in the INSTALL file. That's really all there is to it. This package also installs an application in your OS X's Application folder with the rather clever name "XDarwin". Click on this file and it will launch the XWindows window manager.
To enable rootless mode, i.e. to have Xwindows display in the same environment as Aqua, you need to install a patch which is available from the xonx project at sourceforge. In short:
Installation Instructions
One note: With XDarwin you can select the keymapping to use for your system. However, some keys may not be mapped properly. For example, on my Japanese keyboard the arrow keys are not mapped. http://www.ab.wakwak.com/~tino/darwin/offers a solution. In the XDarwin preferences, select the US Keymapping file and then add the following line to your .xinitrc (located in your home directory): xmodmap $HOME/.Xmodmap. Download the xmodmap.txt file, rename it to .Xmodmap and put it in your home directory. This works perfectly for the japanese JIS keyboards, but for other keyboards, you might need to modify the modmap file yourself.
9. Install Fink package manager
XFree86 as it is, is rather ugly. Now that we have a pure UNIX interface with the FreeBSD layer, we obviously want to do much more with it. Fortunately, that doesn't require much work. Fink is an attempt to bring the full world of Unix Open Source software to Darwin and Mac OS X. Think of it as an add-on distribution (in the Linux sense) for these systems. Read the README and the FAQ, then download and install the Fink binary. Make sure you set up the CVS as well (the how-to is on the Fink website), so you can easily update with new packages.
By default, Fink installs itself and any package into the directory /sw. This may seem strange, but there are very good reasons for it, as explained on the Fink homepage. In my case, I have chosen to have fink install in a different partition: /Volumes/GNU/sw/.
After installing fink, all you have to do is a simple:
cmd-prompt: fink install windowmaker |
and Fink installs the nifty windowmaker window manager for XFree. On my OS X, I actually use blackbox-rootless for a non-obtrusive windowmanager, and I also have installed ghostscript, gv, a2ps, gnuplot, scilab, grace, gimp, xemacs, rxvt, Eterm, and so on....
You can also use Fink to install XFree86, but I prefer the manual installation. It's simple, and the precompiled binaries and the install script make sure no mistakes are made. This straight installation from www.xfree.org just is a clean thing to do.
If you want or need to port UNIX apps to Darwin manually, then please read the Porting Tips first.
10. Modify the 'ls' command to enable colors
First of all, use Fink to install the GNU file-utils (fink install fileutils will do). Then edit your .cshrc file to create an alias for ls with colors, e.g. (Use man ls to find out what the flags do)
alias lc 'ls -GAhlk --color=always' |
Obviously, you want to have your own set of color settings:
|
cmd-prompt: mkdir ~/Library/init/tcsh |
11. Apply useful (freeware) utilities
Finally, a set of utilities I find indispensable in OS X.
-
MacJanitor:
This is a very useful utility for people who do not have their mac running all the time. It will execute the system's maintenance scripts that are usually scheduled to run at night.
-
TinkerTool:
A useful too to enable extra features, such as a transparent Terminal.
-
BetterConsole:
This is a much better system console for you to keep track of gurgles from the underground.
-
ASM:
I missed the Finder menu. This utility gives it back to us.
-
LoadInDock:
Shows the CPU load in the Dock using a very nifty display.
-
SaverLab:
I just love this. It displays screensavers in a window or straight into the desktop. Awesome! It features in one of my screenshots linked below.
-
Notes:
Notes is a replacement for the original Mac NotePad. It is highly efficient with quite a few extras.
There's many more at softrak.stepwise.com or
versiontracker.com.
You can set up your mac to work as an SMTP server using sendmail. The steps are as follows (again become root):
First, you have to edit /etc/hostconfig to add a valid hostname instead of -AUTOMATIC-, otherwise sendmail cannot use an address to send mail. This hostname is supposed to be the valid DNS entry of your Mac. So, if your Mac only has an IP-address and no DNS name, it will be difficult to set up for SMTP. Also change the line "MAILSERVER=-NO-" to "MAILSERVER=-YES-".
Sendmail is very strict to prevent users from being able to access files they would normally not be able to read and will check modes and file permissions on relevant directories. As such, the following comands have to be executed:
|
chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue |
Unfortunately /System/Library/StartupItems/Sendmail is not configured properly. You can manually start the Sendmail command in this directory, but it will fail to start up during boot processes. The reason seems to be that sendmail performs a test and sends output to stderr or stdout or waits for input. Both of these file streams have, however, not been opened yet. So, just put sendmail in the background by adding an ampersand after the command.
Therefore, open the Sendmail script and modify the line:
/usr/sbin/sendmail -bd -q1h
into:
/usr/sbin/sendmail -bd -q1h &
Also edit StartupParameters.plist to replace the word "Preference" by "OrderPreference".
You can start sending mail after the next reboot, or after a manual start of the Sendmail script. To verify if it works, send an email and do a tail -f /var/log/mail.log. To send mail quickly, use the mail command:
Type in "mail mailto:adriaan@tijsseling.com" and press return
After the "Subject:" prompt, type a title, e.g. "Testing sendmail", and press return
Type a message such as "Your tip works/does not work"
Press the key combo Control-D
Note: I noticed that sometimes the file permissions on several directories are reset, forcing sendmail to quit with the usual "group write permission" error. In this case you will have to do the chmod described above yet again.
Eric Belsley from the MacResource site provides info on setting up a POP3 server. It is a very easy procedure. Eudora provides free POP software at their qpopper site. Download and compile. I found that the "make install" command did not work, so I became root and manually moved the executable "popper" to the /usr/libexec directory and the man pages to /usr/share/man/man8/. You also have to edit /etc/inetd.conf to uncomment the pop3 line, and change /usr/local/libexec/popper to /usr/libexec/popper qpopper -s. Finally, all that is left is to "kill -HUP" the inetd process. The guide that comes with qpopper is very detailed. It contains one error in that it mentions mail being in /usr/mail, but instead, it locates at /var/mail. The guide also implies that that it is important that one should make a symbolic link, /var/spool/mail, that points to /var/mail. I did that, but did not verify if it was really necessary.
If you want to set up an IMAP server instead, then you most likely will benefit from this link at stepwise.com!
It is a good idea to take a look at filtering with sendmail. Follow this link for good hints on spam-filtering.
You can find a good setup script on Boris Mann's site. It has been modified recently and now works perfectly.
This is a bloody clever hack that enables you to have different icon sizes in your windows for pre-10.1. Find it at resexcellence.com. Unfortunately, this hack does not work in 10.1 anymore... BUT: it is back in 10.2! To find out how, go to my weblog entry.
Replace default desktop picture
What went on in Apple's head to have a standard unremovable desktop picture, that only 1% of the users really like? Of course, you can select a custom desktop picture using the "Finder Preferences", but before that picture shows during startup, we are forced to view the standard background first. So, of course, we replace it with a picture of our liking. In /Library/Desktop Pictures there is a file called "Aqua Blue.jpg". 10.1 looks for this file during startup and displays it. Replacing this file with one of your choosing (keeping the same name and graphics file format) or deleting it completely, will do just fine.
AppleFileServer checkup script
The apple file server used to have the tendency to quit unintentionally in pre-10.1 OS X. If you are away from your Mac, or controlling it remotely, this is not a convenient "feature". The following is a script I managed to compile with the help of some fellows at comp.sys.mac.system. It can be run in a crontab, such that you won't have to be bothered with it. The script is written such that it checks whether the server is running. If not, it will start the server up again. With 10.1 and above, this is unnecessary, but I keep this around anyway.
#!/bin/sh |
If you want to run the script above as a crontab, you should obviously have it run as root.
So, the root's crontab has to be edited.
To do so, su to root and type the command crontab -e, which will open the root's crontab in vi. Within vi, insert the following line
*/4 * * * * /Users/user/afscheck
in which /Users/user/afscheck is the path to the script above, which obviously might be different for you.
To run the script directly from the command line, first make sure the script has been chmod to 755, then run:
./afscheck
If you run the script from the command line, the following version from Paul Beard will provide more info about the running server:
#!/bin/sh |
Here's my .cshrc file:
setenv DISPLAY :0.0
set prompt = "\! %{\033[33m%}%n%{\033[0m%}@%{\033[36m%}[%c3]%{\033[0m%}: "
source /Volumes/GNU/sw/bin/init.csh
alias foo 'fink selfupdate; fink update-all'
alias sw 'cd /Volumes/GNU/sw/'
alias m 'more'
alias l 'ls -Ahl --color=always'
alias lh 'ls -Al --color=always'
alias lm 'ls -Axh --color=always | more'
alias ls 'ls -A --color=always'
alias verbose 'sudo nvram boot-args="-v"'
fortune
|
The first line is to enable entering XWindows commands in the Terminal.app when XWindows is running. So, I type 'gv' in Terminal.app and the corresponding X11 binary will open in XWindows.
Line 2: my custom prompt... Read here how to do this stuff yourself.
Line 3: sets up PATHs for the Fink binaries
Line 4+: useful shortcuts. Note that the ls shortcuts assume GNU file-utils are installed. The verbose alias is to set verbose booting on automatically.
Last line: pops up a fortune entry at each new shell. Fortune is installed via Fink.
There are still quite a few things I have yet to discover how to "hack".
-Replacing the standard blue background color during startup: This seems to be hardwired in Quartz.
-Franklin Marmon wants to know how to edit the ANSI color scheme in the Terminal. And, in particular, the termcap database.
The solution can be found here
-Christoph Ewering wants the shutdown/restart/sleep dialog to default to Cancel instead of shutdown. He also wonders if for users that are not admin, the shutdown and restart commands can be disabled completely.
The solution can be found here
Don't forget to consult macosxhints.com for more hints.
31996 hits since July 23, 2001
There's already a lot of OS X stuff on the web. This page is simply a cookbook of how I used those resources to put together my system. What follows is intended to be step-by-step instructions for new users to set up their OS X Mac to work in a Unix environment. As such, it is not for everyone. I also don't intend to be comprehensive in listing all the resources that are dealt with elsewere, but do point to links where relevant.
OS X puts all the standard commercial software tools (Word, Illustrator, Matlab) and a unix programming environment seamlessly into a single box. This poses many advantages to scientific programming relative to other desktop systems based on Windows, Linux, or Unix. While many unix and linux packages exist for document preparation, there are many reasons one might want to have access to the standard commercial tools that run only on Windows and Macintosh computers. In the past, however, integrating these computers into the primary computing system has been awkward. When a significant portion of computer work is on Unix systems (eg workstations or clusters dedicated to long model runs), it is desirable to share tools and files between the two systems. OS X's unix core allows nfs mounts, X windows, and most of the common Unix software tools can be run on the Mac so the Mac can be just another Unix computer. Fortran or c code can be directly shared between the mac and other platforms. So, one needs no longer to decide between having a unix system or a office system on one's desk; OS X does both.
Apple has a page on Unix development, which is a good place to start.
While OS X is based upon a unix operating system, it is not, as shipped, a complete scientific platform compared to what you typically get on a new Compaq Alpha, Sun Ultra, or any other typical workstation. It lacks X windows, optimized compilers (there is gcc, but no fortran), and math libraries.
Between Tenon and Absoft, you essentially get the rest of the system. Alternatively, you can assemble the rest of the system from open-source products. Unfortunately, there is no free source for optimized math libraries (although you can compile up BLAS and LAPACK with g77).
Also, as shipped, OS X is setup for the non-technical traditional Mac user, not like a unix box. System administration is also not exactly the same as a unix box.
Here are the things I needed to do to make my Powerbook function for me using open-source tools. There may be better ways around, but without much documentation, this is what I needed to do. (Wherever I give command-line instructions (ie within the shell by running Terminal), the % sign is the prompt for a normal user. The sudo command gives you administrator privileges and can only be run by someone in the admin group.)
Fix file privileges. There are some minor bugs that mess up priviliges on important system files and makes the following impossible. For OS X 10.1, Apple has a utility to restore these, see support article 106900. Under OS X 10.2 (Jaguar), do not use this utility! The same function is built into the "Disk Utility" application.
If PrintCenter or NetinfoManager stop working later, run it again. (You can work around this by running everything as root, but you cannot enable root by the normal methods if things are already messed up!)
Install X windows.
Apple now supplies an X11 package, which you can download here. It comes with a window manager that mimics the OS X Aqua interface, although you can use any rootless window manager, eg, from the fink project (see below). This is a rootless X11, which means X windows are interspersed with Mac windows.
If you don't want rootless X11, you'll need to run Xfree86 from the fink project (see below).
Packages (ie applications and associated libraries and files) are stored on a central server. You install software on your computer that downloads and installs packages that you choose. The software keeps track of what you've installed and can perform upgrades as packages on the server are updated. Installs of precompiled binaries are done from the command line using apt-get or dselect, same as for debian linux. Installs from source are done using the command "fink".
The Mac uses a different binary format from Intel, AMD, and Alpha systems. The G4 uses so-called "big endian" byte order, as do most other Unix platforms. x86 (Intel, AMD) and Alpha (Dec/Compaq/HP) use "little endian". This can cause problems with sharing binary data among platforms. The best solution is to use a platform-independent self-describing format such as netCDF or HDF or even gzipped ascii.
NetCDF is available for OS X from the above link or from fink These OS X ports only support the fortran-77 interface via g77. If you use a commercial fortran-95 compiler, such as NAGware, compile yourself according to these instructions in order to get the f90 interface.
HDF is also available for OS X from HDF web site linked above or fink.
For dealing with raw binary, read this article.
Optimized math libraries.
If you do any matrix operations on a G4, you'll want to use LAPACK and BLAS libraries that take advantage of the vector processor. With vectorization, the G4 is blazingly fast.
Macs are now included in the Automatically Tuned Linear Algebra Software (ATLAS) package. There is even a precompiled G4 library here. ATLAS contains a full tuned BLAS and a partial LAPACK.
You'll need to build the standard LAPACK library separatly and merge as described in the README that comes with the ATLAS distribution. Get LAPACK here.
OS X 10.2 includes optimized libraries in Apple's vecLib framework. There appears to be little difference to ATLAS, and some routines (sgesvd) appear to run slower.
Both NAG f95 and g77 accept the -framework veclib flag to link to veclib. Eg:
% f95 -o prog prog.f90 -framework veclib
Absoft has directions here.
Install other tools as needed. Complete lists exist elesewhere on the web, such as:
Here's some specific stuff I like:
Emacs text editor:
I've found that the best emacs for OS X is the GNU Emacsin it's new carbon version. This is just beginning to be supported, so there are no official binaries, but built versions are available from two sources.
mindlube.com/developer/, this puts nothing in /usr/bin. http://www.porkrind.org/emacs/ has a package installer that unfortunately puts things in /usr/bin messing up the default Apple emacs configuration. You can move his emacs-21.3.50 to /usr/local/bin where it belongs and reinstate the softlink /usr/bin/emacs -> emacs-21.1
For X windows, Xemacs is a good option, and is available from fink).
NetCDF: This is an essential package for atmospheric science datasets. If you use g77, you can get it from fink. If you use a fortran90 compiler, you'll need to download the source from and build it yourself. It builds nicely with NAG f95 following this proceedure.
Plotting atmospheric data fields:
Simple command-line scripting package: grads. OS X version from Whit Anderson at COLA.
Adobe Illustrator. EPS files from Grace, GrADS and NCAR Graphics (eps or cgm) are easily opened and edited with Illustrator.
Microsoft Office. Adobe eps files can easily be incorporated into word documents.
Set up printers. You can add networked lpr printers hanging off unix boxes using Print Center if the printers don't support Appletalk. If PrintCenter crashes, then read fixes for Print Center.