Helioseismology studies the structure and dynamics of the Sun's interior by observing oscillations on the surface. These studies provide information about the physical processes that control the evolution and magnetic activity of the Sun. In recent years, helioseismology has made substantial progress towards the understanding of the physics of solar oscillations and the physical processes inside the Sun, thanks to observational, theoretical and modeling efforts. In addition to global seismology of the Sun based on measurements of global oscillation modes, a new field of local helioseismology, which studies oscillation travel times and local frequency shifts, has been developed. It is capable of providing 3D images of subsurface structures and flows. The basic principles, recent advances and perspectives of global and local helioseismology are reviewed in this article.