Protecting yourself during a earthquake

If you’re inside a building (home or office) and the ground beneath it begins to shake, what should you do? Stand in a doorway? Run outside? If you’re inside a building (home or office) and the ground beneath it begins