If you are presently living in a 19th century adobe home, you may stand in your doorway.
Otherwise, here's what you do:
1. Drop, cover and hold on.
In an earthquake, things fall over, move around and generally fling off shelves. These moving or falling objects can hurt you. Standing in a doorway does not protect you. In addition to stuff flying around, the door will swing back and forth, perhaps violently. The door may strike you, or your fingers may be pinched badly, if you have them jammed in the frame to brace yourself. The door could also fall down, as you see in the photo above.
Instead, if you are dropped, covered and holding on, those things flying around are less likely to hurt you. You drop to your knees, so the quake can't knock you down. You cover under a sturdy table or other piece of furniture to protect yourself from falling objects. You hold on, so your protection moves with you.
[Related: How Will Your Hospital Fare in the Next Earthquake?]
2. If you're inside, stay inside.
This is a hard one. But you don't want to go outside in the middle of the shaking -- because even more stuff is likely falling over outside, like bricks, power lines, all kinds of stuff that can really hurt you.
3. If you're in bed, stay in bed (unless you have a heavy light fixture or other heavy object over your bed). Protect yourself with your pillow.
4. If you're outside, try to move to the open. Move away from buildings and power lines.
5. If you're in your car, stop as quickly and safely as you can and stay in your vehicle. Do not stop under or on bridges, overpasses or trees.
There's much more I could say. But I'll leave it with this: Look around in your home and at work. Think where you could duck, cover and hold on.