Earthquakes can occur anywhere, anytime. One cannot really predict an earthquake so one has to be prepared to deal to with this eventuality.
1) Keep a fire extinguisher, first aid kit, a battery-powered radio, a flashlight, and extra batteries at home, ALWAYS. Learn how to turn off the gas, water, and electricity.
These things and this knowledge will come handy in case an earthquake strikes.
2) If you are indoor, drop down to the ground; take shelter under a sturdy table/bed or some such piece of furniture and be there until the shaking stops. If there is no a table or desk near you, cover your face and head with your arms and crouch in an inside corner of the building.
Protect yourself by staying under the lintel of an inner door, in the corner of a room. Stay away from glass, windows, outside doors and walls, and anything that could fall, (such as lighting fixtures or furniture).
Research has shown that most injuries occur when people inside buildings attempt to move to a different location inside the building or try to leave.
3) If you are outdoors, move away from buildings, trees, streetlights, and utility wires. Seek an open space as far as possible.
Studies have shown most earthquake-related casualties result from collapsing walls, flying glass, and falling objects.
4) If you are in a moving vehicle, stop as quickly as safety permits and stay inside the vehicle. Avoid stopping near or under buildings, trees or electricity/cable wires.
After the earthquake has stopped, be careful and move cautiously, avoiding roads, bridges, or ramps that might have been damaged by the earthquake.
5) If you get trapped under debris, do not light a match and do not move about or kick up dust.
Cover your mouth with a handkerchief or some other piece of clothing.
Tap on a pipe or wall so that rescuers can locate you. Use a whistle if one is available. Shout only as a last resort as shouting can result in inhalation of dangerous amounts of dust.