Most bikes have both a front derailleur and a rear derailleur controlling the position of the chain on the front chain rings and rear cogs or sprockets. The rear derailleur is more complex because the chain cage moves both horizontally and vertically and the chain runs around a pair of wheels. The front derailleur has a chain cage that moves horizontally. To install a chain, deal with each derailleur separately.
Secure your bicycle right side up in a bicycle stand, stand it up with the kickstand or lean it against a wall or post, so the rear and front derailleurs are facing you. Use the gear shifters to align the rear derailleur over the smallest cog, the high gear, and the front derailleur over the smallest chain ring, the low gear.
Grasp the rear derailleur cage by its left wheel and pull down until the wheels are vertically aligned. The top wheel is called the jockey or guide pulley and the bottom wheel is the tension pulley.
Use your other hand to thread one end of the chain counterclockwise around the smallest rear cog. All but about 18 inches of the chain should be hanging down from the right side of the cog. Under the rear cog, the chain end will now point toward the right.
Thread the chain clockwise around the jockey pulley, keeping the chain inside the derailleur cage. Most derailleurs have one or two tabs or guides on the cage. The chain will rub against this tab or guide if not properly installed. The chain end now points toward the left and is between the two pulleys.
Thread the chain counterclockwise around the tension pulley, again making sure to keep it inside the derailleur cage. The chain end now points to the right or hangs off the right side of the derailleur cage.
Continue holding the end of the chain that is now threaded through the rear derailleur. With your other hand, pick up the long end of the chain hanging off the right side of the rear cogs.
Thread this end through the cage of the front derailleur, but do not put it onto the chain rings, as this will make reattaching the chain more difficult. Instead, wrap it around the bottom bracket counterclockwise and bring this end around to the other end of the chain. You are now ready to attach the ends of the chain with a master link or a chain tool.