If you are new to cycling, or if it's been a while since you've been on a bike, you may be wondering how you could possibly use so many gears. You'll probably be surprised to find just how useful all those gears are, particularly when you are riding on different kinds of terrain. Different bikes have different types of gear shifters -- it's a good idea to practice shifting on a nice flat road so you can get a feel for the way the shifters work, and which gears make it easier to pedal vs. which make it harder. Once you're comfortable shifting on the flats, you can start tackling hills.
When exploring your gears, You'll want to find the one that allows you to pedal easily while still generating enough power to move you forward. On a hill, You'll want to be in a lower, or easier gear, allowing you to spin easily without having to force the pedals. You won't be going as fast as you do on a flat road, but spinning at a high cadence (cadence is the speed at which you turn the pedals around) with low resistance will help you conserve energy and prevent injuries. On flat roads You'll want moderate resistance -- You'll still want to be able to pedal easily and quickly, but using a higher gear will allow you to put more power into the pedal stroke. As you gain momentum, you can shift into a harder gear, which produces more power and enables you to go faster. On downhills, you can use the most resistance since You'll already have momentum and gravity pulling you forward.
While the actual shifting levers can be different from one bike to the next, method of shifting gears is generally the same. The chainrings are the big metal rings with teeth near the front of the bike that the chain moves around. Most bikes have either two or three chainrings. By shifting down into the smallest chainring in front, or the one that is closest to the bike, you will find you can pedal most easily. This is the best ring to use for climbing hills.
The middle chainring in the front gives you moderate resistance, and this is the ring used most often on flat roads.
The large chainring in the front, or the one that's furthest from your bike, gives you the most resistance and will be the most difficult for pedaling. This is a good ring to be in when you are going downhill, or if you're on a flat road with lots of tailwind.
The cogs are the group of teethed rings attached to the back wheel that the chain moves around. Most bikes have anywhere from five to nine cogs. Shifting to the largest cog, or the one that's closest to the bike, will make it easier to pedal. Shifting to the smaller cogs, or away from the bike, will make it harder. You'll find that the difference in gears is much subtler in the back, enabling you to really fine tune your shifting.
A rule of thumb that many people find helpful, is that shifting the chain closer to the bike (on the front or the back) will make it easier to pedal, and shifting the chain away from the bike will make it harder.
An important part of selecting your gears is anticipating what's ahead of you. If you see a hill up ahead, You'll want to shift into an easier gear before you start climbing. As the resistance gets harder, or as you find it harder to pedal, You'll want to downshift to an easier gear, which will make it easier to pedal. it's important to shift to the easier gears (this is called downshifting) while you still have momentum on your side. If you wait to shift until it gets really hard to pedal, You'll end up putting too much strain on your shifter (not to mention your knees!) and when you try to shift the chain will probably come off the ring.
it's also a good idea to shift into a slightly easier gear when approaching a stoplight or stop sign -- this will make it easier to start pedaling again, and once you've built up your momentum you can shift back into a harder gear.
One thing to avoid is crosschaining. This is when you are in your smallest chainring in front (the one closest to the bike, and the easiest to pedal) and the smallest cog in the back (the one farthest from the bike, and the hardest to pedal), or vice versa. crosschaining puts unwanted stress on your chain by pulling it at an angle, which stretches the chain and will eventually cause it to break. It also puts stress on your derailleurs (the parts that move the chain between gears) because the chain rubs against the derailleur cages. You can actually see this if you get off of your bike and look. You will also be able to hear the chain rubbing against the derailleur cage. There is no reason you should have to crosschain -- You'll be able to find the equivalent gear by shifting to your middle ring in front, and shifting to an easier or harder gear in the back.
As we said before, the best way to learn how your gears work is to practice. With so many gears to choose from, you should be able to find a comfortable gear no matter what kind of terrain you are riding on.