There are many ways to generate electricity, but most practical ways are variations of these four basic generators:
Most of the methods of power generation are magnetic. In both wind and hydroelectric (water generated electricity) the wind or water turns a magnetic generator directly. With geothermal (heat from the ground), coal, gas, and nuclear, water is heated to steam and the steam turns a turbine, which drives the generator.
The generator itself reamins the same basic design no matter what the force driving it may be. A coil of wire rotating in a magnetic field generates an electric current which is then used for motors, lights, computers, heaters, and so on.
The odd one is thermoelectric generation. It is used almost exclusively in RTG's or Radioisotope Thermoelectric Generators. It uses the decay of a radioactive substance, plutonium-238, to generate heat which is used to directly create electricity. The RTG is hazardous enough that it is only used by space probes going too far from the sun to use solar power.