There are two basic adjustment procedures with indexed derailleur gears. First up are the limit screws, which prevent the mechanism carrying the chain over the end of the cassette. On modern Shimano derailleur gears, up to the new Shadow MTB type, the limit screws are at the back of the upper pivot casting or ‘b-knuckle’. If the chain will not shift into either the largest or smallest sprocket, check that the relevant limit screw is not the cause.
Unscrewing it will allow the mech to move across further. Make sure you don’t go too far, or the chain may come off the cassette and jam the transmission. Shimano’s lower gear limit screw is placed below the high gear screw. Assuming the chain can shift to all the sprockets, any difficulty in shifting into a specific gear is usually due either to sticking control cables, in which case they should be cleaned or replaced, or to cable wear, in which case the indexing must be adjusted. This is done using a barrel adjuster, usually found on MTB transmissions at the shift lever.
A quick method of adjustment is to screw in the barrel adjuster to leave about one turn remaining and then, with the chain running freely on the smallest sprocket, take up slack in the cable and tighten it. The first click of the shifter should move the chain onto the next sprocket. If not, screw the barrel adjuster out a quarter turn at a time until it does.
Next, shift the chain to one of the middle sprockets and use the barrel adjuster to get the chain running straight onto it rather than at a slight offset. This will ensure that the indexing matches the cassette.
Richard Hallett, Cycle's Technical Editor