Servicing the Headset
The headset is the guts that attach your stem and handlebar to the front fork -- it's what lets you turn the handlebars to steer. You may need to service the headset to clean or replace the bearings, to tighten things up as the bike ages, or just to raise the handlebars.
If you notice a "cog-wheeling" sensation as you turn the handlebars, you probably have damaged bearings in the headset. You'll need a new set. Or, (much much worse) you've got damage in the steering tube's bearing races.
Headsets come in two varieties: (1) threaded, where the stem rises from the inside of the headset, and (2) unthreaded, where the stem clamps to the outside of a tube coming up out of the steering tube. If you have an unthreaded headset, go to the threadless headset page.
Begin by loosening the locknut slightly. (The locknut is the first thing below the stem that you can fit a wrench on.) On some bikes, the top lockring has a compression fitting.
If your only objective is to tighten a rattling headset, this is as far as you go in taking things apart. Tighten down the bearing cup until the headset has no "play" (see below) then hold the bearing cup still while you tighten the locknut down on top of it.
Now loosen the bearing cup with your headset wrench (or whatever). I usually tilt the bike so the fork will stay in place. Put a big pan or cloth underneath, to catch any loose bearings.
If the bearings aren't held in a clip, put them in a bowl and count them (top and bottom separately), so you get them back correctly.
Clean the inside of the steering tube. Check for dents in the bearing race (the curved area where the bearings roll).
Lube the bearing races with heavy grease.If the bearings aren't perfectly round, they're worn. Replace them with new bearings.
Reinsert the headset tube into the steering tube.
Put the stem back into the headset tube. Set it to the desired height and snug down the locknut.