So, make sure you're using the proper cable, and you're going to thread it through when it's on the highest gear. So, it's all the way down. Thread it through where the entrance point is. Sometimes you have to like jiggle it around, or maybe you can use a flashlight to try to find the hole. Sometimes it's kind of difficult especially on SRAM shifters you have to bend it like crazy. Sometimes it's easier to pull the hood the opposite direction so you can actually see what you're doing. On other shifters it's easier to pull it back this way like on Campagnolo shifters it's easier that way. Just kind of depends. Feel it out. Make sure it's threaded through properly. Make sure it's going to the correct spot and goes to the piece of housing correctly.
Once it gets through that initial piece of housing make sure you have that ferrule. There are different sized ferrules. There's 4 millimeters and 5 millimeters, and plastic and metal. Make sure they're made for either a shifter or brake so you're using the correct one. You're going to thread it along the bicycle just like it was before making sure that you're going through all the slots that need be. Then once you get to your derailleur just follow the instructions for adjusting the derailleur starting in the highest gear, adjusting your limit screw, and then placing your cable on the bolt with your 5 millimeter hex wrench.
Also, since they're brand new cables some of them aren't stretched. So with the brake and the derailleur you may want to do a couple of shifts, not too hard so you don't break the shifter, just so it stretches out the cable a little bit. You can also pull on the cable while it's on just to stretch it out a little bit, and then readjust.
Once you have it installed and adjusted properly, and you checked all the gears that it goes to properly, then you take your cutters. Cut off the excess. Usually leave about maybe 2 or 3 inches so you can put tools in there, put your hands in there. Make sure you add a tip for the end so your cable doesn't fray and you can adjust it properly in the future. There we go. So the tip's on. The derailleur's adjusted. The new cable is installed.
The reason that you'd want to install new cables, both brake and shifter, is because they get corroded. They're made out of metal. Sometimes they get rusted. Also, inside the actual housing you'll get sand and dirt and things like that. Then the shifting and the braking will not work properly.
Once you're all done make sure everything's all back together. Try it out on the stand or try it out upside down before you actually go riding to make sure that everything is set and your brakes are stopping properly.
And that's how you install cables in housing.