Before farming, people hunted animals and gathered plants (such as berries) for food: they're called hunter-gatherers.
They lived in whatever provided shelter: caves were a good candidate, but also huts made from whatver was available (mud, bamboo, wood, etc.).