Connecting a generator directly to your household wiring can be deadly to you and others. A directly connected generator can 'backfeed' onto the power lines connected to your home. Utility transformers can then step-up or magnify this backfeed to thousands of volts—enough to kill a utility lineworker making outage repairs a long way from your house. You could also cause expensive damage to utility equipment and your generator.
To power your household circuits directly, you must install a transfer switch. Whether automatic or manual, a transfer switch makes sure your household wiring, or selected circuits to be supplied by the generator, can't be connected to the utility grid and to your generator at the same time. That prevents backfeed -- and the risk of having your generator damaged or destroyed if utility power is restored while the generator is connected to your wiring.Working around your household fuse or breaker box can be dangerous, so the safest course is to hire a licensed electrician to install the switch for you.
Please note: Portable generators aren't intended to be connected directly to your household wiring, but to the items you wish to power. Use properly sized, outdoor-rated cords to power chosen end uses such as a stove, refrigerator, furnace, water pump, or lamps. If a portable unit is to be hooked to household circuits rather than to appliances themselves, it needs a transfer switch and a dry, solid mounting in a properly vented area, just as a permanent unit does. Portable generators need to be grounded, just like other major electrical devices. Many have a grounding lug on the chassis so you can run a copper grounding wire to a pipe sunk into the earth; see your owner's manual for details.
A particularly dangerous practice is moving a generator around on a truck and simply plugging in to an outdoor outlet to supply power to a friend or relative's house. The practice involves a serious risk of injury or death from back-feed or from sudden restoration of utility service. That's why it's prohibited by the National Electric Safety Code.