Human movements in the real world and in cyberspace affect not only dynamical processes such as epidemic spreading and information diffusion but also social and economical activities such as urban planning and personalized recommendation in online shopping. Despite recent efforts in characterizing and modeling human behaviors in both the real and cyber worlds, the fundamental dynamics underlying human mobility have not been well understood. We develop a minimal, memory-based random walk model in limited space for reproducing, with a single parameter, the key statistical behaviors characterizing human movements in both spaces. The model is validated using big data from mobile phone and online commerce, suggesting memory-based random walk dynamics as the universal underpinning for human mobility, regardless of whether it occurs in the real world or in cyberspace.