A Mac O/S (10.2, 10.3) Cheat Sheet

31 Mar

Some of these tips are obsolete, applying to (mostly) Panther and Jaguar.

All of these tips are things that I have assembled from other sources. Things I found useful on a regular basis. I take no credit for these tips/hacks. Most of them came from MacOSXHints.com. Some came from MacInTouch.com and the defunct ResExcellence.com I had been saving these tips for personal use in a little text file and only recently had to urge to add some techie content to my otherwise personal web site. In places where I had retained a reference to the originating source, I indicate it.

If you recognize a tip here as something you came up with, please tell me and I will give you credit, link back to the original tip and/or your personal web page if you like.

All of the tips here assume you have some familiarity with the Terminal/Shell and that you have the Developer tools installed. If you are having problems with something here, email me. and I will either correct the error or try and point you in the right direction.

Also the Mac O/S has been updated a few times since I first wrote this. Do test any tip before you assume it works on your installed version.

Disclaimer:

Don’t blame me if you try something here and you lose years of irreplaceable data, screw up your Mac, cause the ground to open under your feet and send the Earth careening into the sun. You are responsible for your own actions. This stuff works for me. So make copies of any files before you change them. Think about what and how you are doing something so that, if it fails, you can back out of the changes you have made.

 

I have not included the shell prompt. Assume that each line is to be entered one at a time. Terminal lines and paths always look like this respectively:

Command -a -b -C
/Volumes/MacHD/etc/Path/To/one/Particular/File

And if you are confused as to what some of the characters are and where spaces are just copy/paste the line into Terminal. That’s what I do.


Bless The System Folder

System_Folder_iconIn the Good Old Days™ before Mac O/S X all you needed to make a bootable system was just two files from the System Folder, the files were called Finder and System. To bless (or make bootable) all you had to do was verify that the System Folder icon had a little Mac icon on it. If it didn’t all you had to do was open and close the folder and if both files were the correct ones the folder displayed the System Folder Icon and you were good to go. It’s a bit more complicated these days.

let’s not get into System Enablers and other model-specific extensions as they were generally an of the System 7.5 days. Did I ever say I am awfully glad System 7.5.x is dead and buried?

Lets say that you have made a clone of your boot drive/partition in case you have a disk failure. This would be a Good Thing To Have. Also a Good Thing is to actually boot from the cloned image after you create it to verify it works. If it doesn’t there could be a couple of problems. The first thing to try is to repair permissions. Something you should do first almost always when having OSX problems.

Assuming that you have repaired permissions and verified that you have the correct partitioning scheme on the drive the next thing to do is to bless the system folder. Not as easy as under OS9 and before but not too bad. Open up a terminal and do this:

sudo bless -folder /Volumes/DRIVENAME/System/Library/CoreServices
Replace “DRIVENAME” with the name of the partition that contains the system to be blessed.

A couple of caveats. Unlike the classic Mac OS you can’t just drag files from one drive to another, you have to use a utility designed to do it. Carbon Copy Cloner is a good way to do this and uses the Unix tools built into Mac O/S X to do the cloning. There are many others.

Also if you have an Intel-based Mac the boot drive has a different partitioning scheme. You will need to do this first:

Open Disk Utility and select the drive you want. Click the Partition tab and then the Options button. Select the GUID partitioning scheme. Partition/format the drive, clone it, repair permissions and bless the system, voila! And please remember that re-partitioning your hard drive erases everything on it.

March 31 2006


Make Extensions Work in Firefox 1.5

Staying on the bleeding edge can be annoying, especially when you download a new version of Firefox and discover that your current extensions don’t work with the new version. you can “fix” this.

  1. Open Firefox.
  2. Enter about:config in the address bar.
  3. Right-click on the list, select New > String(if you don’t have a two button mouse, control-click).
  4. Enter app.extensions.version as the preference name.
  5. Enter 1.0 as the app.extensions.version.
  6. Quit and then relaunch Firefox.
  7. Enable those extensions.
  8. Quit and then relaunch Firefox and you should be good to go.

Be careful, activating an extension in a version of the browser it was not designed for could do bad things. But then you already knew that, didn’t you?

March 31 2006


Terminal: Prevent “man” From Clearing the Window

I never did understand why Apple did this. When you are finished reading a man page and exit, the screen clears. I don’t like this. Yeah I could open another terminal window, but it is still annoying. Here is how to prevent this behavior.

Go to Terminal Preferences

Set the pop up menu to “vt100”

The next time you launch terminal that behavior is gone. Joy!

March 31 2006


Preference Files: The First Troubleshooting Step

One of the first things I learned in Mac troubleshooting was:

A damaged preference file can cause an application or the OS to crash or otherwise misbehave.

That was true when preference files had their one Preferences folder in the System Folder in the Classic Mac OS. And is still true today in Mac OS X.

When an application starts crashing or acting strangely the easiest and fastest first step to fixing that problem is to move or delete it’s preference (or settings) file(s). In Mac OS X those files are are generally here.

/users/YOURUSERNAME/Library/Preferences
/Library/Preferences

Everything in each of those folders is a file that contains the settings for all of the programs on your Mac. Like settings that can be changed in the Preferences window of the program. Sometimes even your serial number for that program is stored there.

Generally speaking you can safely delete any file in here and the worst that will happen is that the program will revert to it’s default settings. Though it is usually better just to move the file to the desktop so you can put it back if that isn’t the problem. Here’s how it works.

An application, let’s say Quicktime player, is crashing upon launch, or when you do a particular thing, or randomly. And nothing else (no other program) seems to be affected

    1. Quit out of the Quicktime player.
    2. Open the Preferences folders and look for files associated with Quicktime.
    3. Move the preference files for Quicktime in your home/Library folder to the desktop.
      • com.apple.QuickTime Player.plist
      • com.apple.quicktime.plugin.preferences.plist
      • com.apple.quicktimeplayer.plist

Note that the quicktime.plugin.preferences.plist may not be part of the problem as it is for the Quicktime
web browser plug in. I prefer to remove all of them, just to be safe.

  1. And the one in your /Library folder.
    • com.apple.QuickTime.plist
  2. Re-open the Quicktime player and see if that has fixed the issue. If it has you are good to go, if not you can put them back, replacing the ones that Quicktime just created.

Apple has also thoughtfully provided a tool to check and see if a preference file is damaged or not. But that file has to
follow (I believe) Apple’s naming conventions and use the standard (.plist) XML format.
Files that don’t end in “.plist” do the same thing but in a different manner so this utility will not check those files.

To check all of the .plist files on your system you would execute the following two terminal commands

sudo plutil -s ~/Library/Preferences/*.plist
sudo plutil -s /Library/Preferences/*.plist
The “-s” switch tells it to display only problem files.

That’s a quick way to tell if any .plist file on your Mac is damaged. And probably the best way (aside from removing the file) to determine if the problem you are having is simply a damaged preference file.

March 31 2006


TCSH Shell Startup Script

The shell that Apple provides is pretty bare bones. There are people who have pages and pages of shell customizations. Me, I have just a few that make my life easier.

Open a terminal session and paste these lines in one at a time.

echo "source /usr/share/tcsh/examples/rc" > ~/.tcshrc
echo "source /usr/share/tcsh/examples/login" > ~/.login
echo "source /usr/share/tcsh/examples/logout" > ~/.logout

This will point three shell startup files in your home directory to the originals here: /usr/share/tcsh/examples/. These files then pont elsewhere for aliases and other things. Essentially these files are chained together. Confused yet? This one tip took me weeks to get just right.

This file has the Apple custom aliases: /usr/share/tcsh/examples/aliases

Don’t fiddle with that file! Add your aliases to the aliases.mine file like I show you below. Once the Apple default aliases file runs it runs your aliases.mine file:

/usr/share/tcsh/examples/aliases.mine

I Add these aliases to aliases.mine (YMMV):

alias topu "top -u -s5"
alias ftxt 'find . -name "*.txt" -exec grep -il \!:1 {} \;'
alias dir "ls -Fal"

#1 will update the TOP program every 5 sec, a little more slowly than the default

#2 type: ftxt hello to find all plain text files containing the string "hello".

#3 type: dir to get a directory listing formatted with these options:

long format
hidden files
add / or * to directories and symlinks


Customize the TCSH Shell Prompt

The Apple standard shell prompt was ugly and gave me more information than I needed. To modify the prompt use the set prompt = command

The most used shell variables are:
%/ Current working directory
%~ Same as the above, but it will replace /Users/Username with ~
%M FQDN
%m domain name
%t,%T time of the day in 12- and 24-hour format respectively
%p,%P time of the day, with seconds, in 12- and 24-hour format respectively
%n user name
%# 'default' character prompt:
expands to '$' for normal users
expands to '#' for root user

For example the default prompt for tcsh:

set prompt="[%m:%c3] %n%#"
However I prefer this simpler, shorter prompt which I add to the end of the ~/.tcshrc file.
set prompt="%/\n> "

This gives you the current absolute path, a newline, and > as a prompt with a space after it


Customize the BASH Shell: Aliases and Prompt

Of course as soon as I had figured out how to set up the TCSH shell quickly and easily, Apple goes and changes the default shell in OSX 10.3 to BASH (sigh). This time it took a little less time to figure out what to do.

To customize the BASH shell I did a little digging via Google and found where the files were that needed to be modified to suit my simple customization needs. Yes this is actually something I figured out all by myself (golly!) Apple does not include the .bash_profile file by default but it is easy enough to create:


CD ~/
sudo pico .bash_profile

Here is what I have added/customized. This combines the aliases I want plus changes to the environment. In the TCSH changes (above) these changes were in multiple files. An improvement in my book!

export CLICOLOR_FORCE=yes
alias topu='top -u -s5'
alias ftxt='find . -name "*.txt" -exec grep -il \!:1 {} \;'
alias dir='ls -FalGh'
alias ll='ls -FalGh'
PS1="\w\n> "

This will do the following:

force color in the terminal
set 4 aliases
modify the prompt the same as the TCSH above


Modify Daily CRON to also run Disk Permissions

Incorrect disk permissions seem to be the dirty little secret of Mac O/S X. Running repair permissions fixes a multitude of problems. I recently found out thru an Apple support tech that it is a really bad idea to repair disk permissions from a different volume (except a Mac OSX install CD!) when the versions of Mac O/S X are different. So if you have 10.2.8 installed and your boot CD is 10.2.3, don’t do it. Every time the O/S version changes so do the default permissions.

 

Lesson one: always repair permissions booted from the disk you are repairing.

The only exception to that rule is the O/S install CD/DVD

 It is easy enough to do this from the Disk Utility. Or you can do it from the terminal:

sudo diskutil repairPermissions /

It seems to me (and the person who thunk this tip up) that the best way to keep the permissions set correctly is to run them automatically. So we use the built-in CRON command and add to the nightly housecleaning duties. For this to work your Mac has to be on at night. Alternatively you can run one of the many utilities that will kick off these scripts manually.

The script "/etc/periodic/500.daily" looks for a file "/etc/daily.local" when it runs. If it finds this file, it will perform whatever commands are contained inside. Here is what you do to set this up

cd /etc/sudo pico daily.local diskutil repairPermissions / >> /var/log/daily.out

Exit Pico, saving as you go, then in the terminal:

sudo chmod +x daily.local


ManServer lets you read MAN pages in a browser

this is handy if you hate looking thru MAN pages in the terminal. The original tip is here on MacOSXHints. The direct link to this handy little CGI is here:

https://github.com/silviuvulcan/manServer

Here’s what you have to do to get it to work:

  • Open the “.pl” (PERL) file in a text editor and find the line that reads $ENV{'PATH'}
    = "/bin:/usr/bin";
  • Add another line below that reads:
    $ENV{‘MANPATH’} = “/usr/share/man:/usr/local/man:/usr/local/share/man:/usr/X11R6/man”;
  • Put that file into /Library/WebServer/CGI-Executables
    • Optionally if you don’t like the format of the resultant web page
      (like me) do this
    • Find the line that reads "<A HREF=\"$root$request/$f\">$f</A>&nbsp;\n";
      It should be in the sub-routine listDir.
    • Replace ' &nbsp' with '<br>' to put each manpage link on a new line
  • Make sure it’s executable:
    chmod +x manserver
  • Start personal web sharing in the sharing preferences panel. If it is
    on, stop and start it.
  • You can now access all local man pages by going to http://127.0.0.1/cgi-bin/manserver (which will only work on your local Mac)

Put the date in the menu bar (Jaguar – Mac OSX 10.2)

I like to have the day, date and time in the menu bar. Apple does not provide that as an option. Here is how to do it. Note that I could not get this to work under OSX 1.3. There is another hack for that.

Launch PList Editor as root. You can use Pseudo or PathFinder to do this

Once you have PList Editor open as root you need to open the relevant PList file here:

/System/Library/CoreServices/Menu Extras/Clock.menu

Once you are there you have to dive into the contents of the package

[Contents]/Resources/English.lproj/Localizable.strings

That particular file is inside the Clock Menu package, but PList Editor treats it just like another folder.
Once you have the proper file loaded, click the reveal triangle next to ROOT and look for this entry:

MBC_CLOCK_FORMAT_STRING

And change it to:

%a %b %d - %time%p

Which gives a date and time format that looks like this:  Day Month Date – 0:00PM

Save your changes in PList Editor and quit.

Either reboot, log out or use Activity Monitor to force quit SystemUIServer and your changes should now be there.


Add the date to the menu bar clock in Panther (Mac OSX 10.3)

I tried the above hint in Mac OSX 10.3 and no luck. Fortunately MacOSXHints came to the rescue as it often does. Do this:

sudo pico ~/Library/Preferences/.GlobalPreferences.plist

If you don’t have that section in your .GlobalPreferences.plist open the International preference pane, click on Formats,
select the Times tab then click on Customize. Don’t change anything, just quit System Preferences.

Look for the AppleICUTimeFormatStrings section near the top of the file. Modify the Key2 string:

<key>2</key><string>d' 'h':'mm':'ss' 'a</string>

Which gives a date and time format that looks like this:  Day Date 0:00PM

The original hint is here on MacOSXHints.com


Launching an OS X application as root

The trick here is realizing that the actual executable is inside the package which is what we see with the pretty icon. The Unix core of OS X, however, sees it as what it really is: a folder (or directory if you prefer). Adding the ampersand (&) to the end of the command launches as a separate process so you can continue to use the terminal.

sudo path/to/application/Contents/MacOS/app_name &

For example:

sudo /Applications/TextEdit/Contents/MacOS/TextEdit &


NetSend to PCs

Assuming that you have not turned off the Windows Messenger service this can be handy to send a quick alert to someone on a PC. Doing this will pop up a dialog box with your message in it and the name of the PC it is being sent from. replace [NETBIOS NAME] with the name of the computer you are sending to.

smbclient -M [NETBIOS NAME]

You will get the following back in the terminal

added interface ip=130.33.202.14
bcast=130.33.207.255 nmask=255.255.248.0 Connected. Type your
message, ending it with a Control-D

Type your message and tap CONTROL-D and in a few seconds the message
pops up on their screen:

messenger


Samba Options

Samba is the server that Apple includes with OS X to allow you to share files with PCs and participate in a PC Workgroup or Domain (Active Directory or NT4) using the SMB protocol. There are some options that Samba can set that are not available in the GUI. To change these you need to edit a configuration (.conf) file:

sudo pico /etc/smb.conf

You will be adding lines in the [GLOBAL] section. Add them to the end of that section or change the pre-existing entries

encrypt passwords = yes
workgroup = HOME
local master = YES
netbios name = STEVEZ-G4
server string = Mac
OS X 10.3 Running Samba

The lines above are pretty simple. I like to encrypt passwords. The name of the workgroup at home is, oddly enough “HOME.” The workgroup name on the PCs have to match. I set my G4 as the Browse Master (Local master in SAMBA parlance) which means all the other PCs look to this one to maintain the “Network Neighborhood” list only one computer should be the browse master

At work there will most likely already be a Workgroup or Domain name. Set workgroup to that and be damn sure you set local master to “no.” Otherwise you are likely to piss off the local network admin as your Mac tries to take over Browse Master duties from the Primary Domain Controller (or Domain Controller in Active Directory).

To turn off Browse Master on a PC you go into control Panel and look for the Services control panel (Possibly under Administrative Tools). Find “Computer Browser” in the list, double-click on it and set the startup type to disabled then click stop.

The NetBIOS name is the name of your computer in Network Neighborhood. It needs to be less than 13 characters and be comprised of only “DOS legal” characters. Avoid spaces in the name. The server string can be anything, it is optional and will display a descriptive phrase next to the computer name in Network Neighborhood. All this makes it easier to share files with any PCs you have at work or home.

The O’Reilly Samba manual is on your Mac in HTML format:

Mac OSX 10.3 Panther: file:///usr/share/swat/using_samba/toc.html

Mac OSX 10.2 Jaguar: file:///usr/share/swat/using_samba/index.html


Let’s save the best for last

This one is easily one of the best Apple K-Base documents. It is about troubleshooting Mac OSX Startup issues:

http://www.info.apple.com/kbnum/n106464