Early Sunday morning the ground started to rattle in Alaska, and those who didn't sleep through the 7.1-magnitude earthquake reacted in many different ways.

Some people ran outside of their homes, while others pressed themselves into doorways. Some people hurried down the stairs of hotels in their underwear, while others squatted under kitchen tables.

But what's the best thing to do when you feel the floors start to sway?

Emergency officials have a few tips and one of them is stay inside.

What should I do if I wake up to an earthquake?

"Stay in bed," said Sam Johnson, preparedness specialist with the American Red Cross of Alaska.

Johnson said Alaskans should generally follow a simple mantra when an earthquake hits: "Drop, cover and hold on."

When you're in bed, she said, you've already dropped. And as long as nothing can fall on you -- including a ceiling fan, a large headboard or shelves -- you just, "cover your head," she said. "Just stay as stationary as you can."

Buildings in the U.S. are resilient, and people shouldn't have to worry about them collapsing, said Jeremy Zidek, public information officer with the state's Division of Homeland Security and Emergency Management.

"There may be significant damage, but a pancake collapse is not very likely," he said. In other lands, it may be more of a problem, he said. "If you were in Tibet, I would try to get out of the building as quickly as possible."

Chris Nance -- chief communications officer at the California Earthquake Authority, a nonprofit that provides earthquake insurance for homeowners and renters -- said if you can quickly roll out of bed and under a table, you should do that. If not, just cover your head with your arms.

When the earthquake hit at 1:30 a.m. Sunday, Johnson said she stayed in bed and shielded herself with pillows. Zidek said he squatted next to his bed, and held onto the frame.

Rob Fitch, an emergency programs manager at Anchorage's Office of Emergency Management, said you should keep a pair of heavy gloves and shoes under your bed so that after the shaking stops you can get out of your house and past any broken glass or debris.

When should I run outside?

Probably never, Nance said.

People will get thrown to the ground in a big earthquake before they make it outside, he said. They could also get hit by falling objects on their way to the door, Johnson said. Outside, there are also light poles, power lines and trees that can fall, she said.

"The number one cause of injury in the U.S. during earthquakes is from falling objects," Zidek said. "The second most common cause is people being thrown to the ground."

Instead of sprinting outside when you start to feel the ground shake, you should look around and ask: Can anything fall on top of me? Am I near windows?

If the answers are no, drop and cover your head, Johnson said. If the answers are yes, move and get under something sturdy like a desk or table, she said.

"If you're on the couch, just ride it out," Fitch said. "If you're next to a nice, sturdy kitchen table, do the duck and cover thing."

Nance said you should use one hand to hold the leg of the table so it doesn't move and put your other hand over your head for reinforcement, in case anything heavy falls on the tabletop.

What if I’m already outside?

"Just stand there and look at your surroundings and make sure that nothing can fall over," Fitch said.

Michael West, state seismologist, said that if you're outside and away from buildings, "you're probably in a decent place."

If people are close to buildings, they should be aware of building facades that could fall off in an earthquake, he said.

And then there are the light poles, power lines, trees and cars, Johnson said.

What should I do if I’m on the 15th floor of a hotel?

Johnson said she would recommend staying in your hotel room.

"Yeah, maybe the building's swaying, but it's built to do that," she said.

Just like if you were in your home, she said, you should ensure that nothing can fall on you, get down and cover your head. Trying to get down the stairs while the floor shakes may just increase your chances of injury, she said.

What about standing in a doorway?

Fitch called standing in the doorway an "old adage" that, in most cases, is no longer true. In modern homes, doorways aren't stronger than other parts of your home, he said.

Plus, doors can swing as the building sways, potentially causing injury, Johnson said.

What should I do if I’m in a mall?

"Duck and cover," Fitch said, and get away from big panes of glass.

What if I’m driving?

Most of the time, you won't notice an earthquake if you're in a car, Fitch said.

But if you do, stay in your car. "That's the best thing in the world," he said.

If you're driving, you should pull over to the side of the road and stop -- avoiding power lines and overpasses, according to the U.S. Geological Survey.

If you're walking in a parking lot, get in your car, Fitch said.

"The worst thing is cars bouncing across parking lots and crushing people," he said.

How about if I live near a coast?

"If you're right next to the coast and you feel violent shaking for 20 seconds or more and it's hard to stand -- that's your warning sign to evacuate," Zidek said.

You need to head to higher ground. Soon after an earthquake, the National Weather Service typically posts online whether or not a tsunami is expected.

What should I do after the earthquake stops?

You should check if anyone's hurt, Fitch said. Also, evaluate your home.

If you smell gas, turn off the gas. Check your water main for breaks, Zidek said.

But how do I detect a natural gas leak?

Inspect gas-fed appliances such as your furnace or water heater, as well as the meter outside your house.

Sniff the air. A rotten-egg smell indicates a leak. Also, inspect the gas pipe for damage. Listen for hissing that may be coming from a leak.

If you believe there's a leak, go outside. Don't call for help from an enclosed area that may contain natural gas -- cellphones can spark an explosion.

You should call Enstar's 24-hour response line at 1-844-Smell-Gas (1-844-763-5542). Enstar personnel will check your system for free.

It's also a good idea after an earthquake to make sure that vents in boiler rooms or other small spaces with gas-fed appliances were not jiggled shut by the shaking.

What if my drinking water is cloudy?

Earthquakes can shake loose sediments that appear in private water wells, discoloring drinking water or leaving it cloudy. After Sunday's quake, the state Department of Environmental Conservation received an uptick in calls from homeowners with drinking water that was suddenly murkier than normal.

The water should be boiled, said Cindy Christian, acting manager for the drinking water program at DEC.

Well owners should also have the water tested for coliform bacteria, a step that should be taken once a year or following a major quake, such as this recent one or the 7.9-magnitude Denali earthquake in 2002, she said.

Well-water owners with discolored water also "may want to reduce water usage to allow sediments and particulate matter in aquifers to settle out. Trying to purge the system may result in additional disturbance to the aquifer," the DEC said in a statement.

What else should I do after an earthquake?

If you have a home heating oil tank outside your house, you should inspect it, along with the furnace or boiler and the rest of your heating system.

Some oil tanks are supported on stands that may have shifted during an earthquake.

"Earthquakes can loosen or damage stands, tanks, fittings, and lines, causing leaks," the state Department of Environmental Conservation said in a statement. "Even minor drips can add up to significant loss of fuel, increasing expense and potentially causing environmental contamination."

According to Zidek, it's also not too early to start preparing for the next earthquake.

On average, Alaska has more than 10,000 earthquakes every year, he said. Once a year, Alaskans will experience a 7.0- to 8.0-magnitude earthquake. Every 13 years, on average, one will be larger, according to the Alaska Earthquake Center.

Zidek recommended looking at your gas meter and figuring out how to shut it off. If that entails a wrench, you should get the appropriate wrench and put it somewhere you can easily find it, he said. But experts advise to not turn off the gas unless there's a leak -- it's difficult to get it back on.

You should also make a plan with your family about the best places to go in your house if an earthquake hits, he said.

Zidek also recommended that everyone have a seven-day emergency kit filled with food, water, an indoor heat source and communication devices -- like back-up power for your cellphone and a hand-crank radio.

"The more people can do to prepare and be self-sufficient, the better off they're going to be," he said.

Reporter Alex DeMarban contributed to this story.