If you find the ground shaking beneath your feet, there's an international consensus on how you should act. Earthquake safety boils down to three basic steps:
1 - Drop to the ground
2 - Take cover by getting under a sturdy desk or table
3 - Hold on to it until the shaking stops.
If there isn't a table or desk near you, drop to the ground in an inside corner of the building and cover your head and neck with your hands and arms. Do not try to run to another room just to get under a table.
If you are in bed, hold on and stay there, protecting your head with a pillow. You are less likely to be injured staying where you are. Broken glass on the floor has caused injury to those who have rolled to the floor or tried to get to doorways.
If you are outdoors, move to a clear area if you can safely do so; avoid power lines, trees, signs, buildings, vehicles, and other hazards.
If you're driving a car, pull over to the side of the road, stop, and set the parking brake. Avoid overpasses, bridges, power lines, signs and other hazards. Stay inside the vehicle until the shaking is over. If a power line falls on the car, stay inside until a trained person removes the wire.
If you're at the movies or a sports game, stay at your seat and protect your head and neck with your arms. Don't try to leave until the shaking is over. Then walk out slowly watching for anything that could fall in the aftershocks.
If you're by the shore, drop, cover and hold on until the shaking stops. Estimate how long the shaking lasts. If severe shaking lasts 20 seconds or more, immediately evacuate to high ground as a tsunami might have been generated by the earthquake. Move inland 3 kilometers (2 miles) or to land that is at least 30 meters (100 feet) above sea level immediately. Don't wait for officials to issue a warning. Walk quickly, rather than drive, to avoid traffic, debris and other hazards.
If you live downstream from a dam, you should know flood-zone information and have prepared an evacuation plan. Catastrophic failure is unlikely, but dams can fail during major earthquakes.
The main point is to try not to move and to immediately protect yourself as best as possible where you are. Earthquakes occur without any warning and may be so violent that you cannot run or crawl; you therefore will most likely be knocked to the ground where you happen to be. You will never know if the initial jolt will turn out to be start of the big one.
In addition, studies of injuries and deaths caused by earthquakes in the U.S. over the last several decades indicate you are much more likely to be injured by falling or flying objects (TVs, lamps, glass, bookcases, etc.) than to die in a collapsed building. "Drop, Cover, and Hold On" offers the best overall level of protection in most situations.
There are also a few things you really shouldn't do.
You might have heard that the safest place to be in a house is a doorway. Not true. An early earthquake image of California is a collapsed adobe home with the door frame as the only standing part. From this came the belief that a doorway is the safest place to be during an earthquake. In modern houses and buildings, doorways are no safer, and they do not protect you from flying or falling objects. Get under a table instead.
Don't run outside. Trying to run in an earthquake is dangerous, as the ground is moving and you can easily fall or be injured by debris or glass. Running outside is especially dangerous, as glass, bricks, or other building components may be falling. Again, you are much safer to stay inside and get under a table.
Information provided by The Great California Shake Out.