A worn brake cable -- or damaged cable housing -- makes it harder to apply the brakes, and can keep the brakes from rebounding fully away from the rim. Damaged derailleur cables make shifting to a smaller cog or smaller chainring unreliable.
If the cable is only dirty, it can be cleaned out, and may work good as new. See our section on cable cleanout.
Check the cable housing (the sections of big black tube that surround the cable). If you see a sharp bend, the housing needs to be replaced. Look at the exposed sections of cable. If you see fraying, breaks in the individual wires, or loosened wires, the cable itself must be replaced.
To replace a cable, buy a new cable, a section of cable housing, a cable end-cap, and housing end-caps.
First thing you should know: brake cable housing has metal wrapping that goes in a circle around the cable, while derailleur cable housing has metal strips that run the length of the cable. Derailleur cable housing has a smaller hole (for the smaller cable) than brake cable housing. Don't substitute one type of cable housing for the other!
Slide the cable housing caps away from the housing. Now slide caps and housing off the cable.
As you remove the old cable, place the parts in a line, so you can easily see where everything goes. Even if you're planning to replace the housing, keep the old sections so you can cut the new pieces to match!
Remove the old cable from the handlebar end.
Pull the barrel out of the retainer by lining it up with the slot in the clip. Push the barrel and cable sideways out of the slot.
Shove back on the cable so the barrel comes out of the shifter mechanism. Grab the barrel and pull the cable through.
(In most cases, removing the bolts on the gear indicator gauge won't expose the cable housing. But if you can't see any other way to disassemble the shifting unit, try it.)
While you're at it, clean the exposed surfaces, and clean the cable pathway into the barrel adjuster.
Grab the barrel and pull the cable out of the shifter.
Slide on the front end cap, cable housing, and back end caps for each section of housing. Fit the housing into the mountings at the handlebars, and at each relay mounting of the frame.
Perform final adjustments of the cable tightness with the barrel adjuster. For derailleur cables see the section on tuning the front or rear derailleur . For brakes, see the brake tuneup section.