How deep would a moonbase have to be dug for radiation protection? The atmosphere of the earth protects us from cosmic rays and other kinds of space radiation. On the moon, there is little to no atmosphere, so anyone on the surface of the moon is directly exposed to space radiation. By digging an underground shelter it is possible to attain shielding from space radiation.
How deep would such a shelter need to be to provide the equivalent protection afforded by the Earth's atmosphere?
 A: On the surface of the Moon, the main source of radiation is energetic solar particles (mostly protons and electrons) and galactic cosmic rays (GCR). (The GCRs come out of the Solar system.) The gamma radiation (as a primary particle) is negligible. (The gamma flux in the space is very low...)
According to this article, most of the particle showers won't penetrate more than 0.5 m of lunar soil (with a density of 1.4 g/cm$^3$). (According to this presentation, the density of lunar soil ranges from about 1 g/cm$^3$ to 2 g/cm$^3$.) The showers have a sharp peak in the [energy deposit - penetration depth] relationship. After which the energy deposition usually drops to less than 10% of the peak value. (Only lightly ionizing particles remain.)
Although they couldn't study the contribution of neutrons (created in the particle showers), which can penetrate more rock than the charged secondary particles. (On current spacecrafts, 30-60% of the total equivalent dose might come from neutrons.)
Based on the article, about 0.5-1 m of soil might be sufficient.
Although the radiation level will be still higher than on the surface of Earth, it is hard to tell more without experiments or simulations. The problem is with the neutrons (and high energy muons). For these, the energy loss is not continuous, but characterized by discrete events. Thus they can often penetrate more material than expected by continuous energy deposit approximation. Thus also non-trivial if '8 km' of air can be substituted by 4 m of rock (as suggested by @CuriousOne). (Also partly because of the different composition of rock and air.)

A: Let's assume that the Cosmic radiation hitting the moon comes from either the Sun or any sources outside our solar system.
The gamma radiation component
In this article one can read:

It can pass through the skin, but it is absorbed by a few centimeters of body tissue or a few millimeters of aluminum. Gamma radiation is the most penetrating of the three forms of cosmic radiation. It can easily penetrate body tissue. It requires several centimeters of lead or about 1 meter of concrete to absorb it.

Now, the relative densities of the Moon's surface and that of concrete are about $3.4$ and $2.4$, respectively. This means the surface of the Moon absorbs the gamma radiation up to a depth of about $\frac{2.4}{3.4}=0.7$ times one meter which is obviously $0.7$ meter.
The electron and proton component
From the citation, we can infer that the electrons and protons penetrate less deep than the gamma photons do.
Conclusion
Hence, to be safe inside a station on the moon, it suffices to put it about $1.4$  meter below the moon's surface.
