The Pauli Exclusion Principle states that, in an atom or molecule, no two electrons can have the same four electronic quantum numbers. As an orbital can contain a maximum of only two electrons, the two electrons must have opposing spins. This means if one electron is assigned as a spin up (+1/2) electron, the other electron must be spin-down (-1/2) electron.
Electrons in the same orbital have the same first three quantum numbers, e.g., \(n=1\), \(l=0\), \(m_l=0\) for the 1s subshell. Only two electrons can have these numbers, so that their spin moments must be either \(m_s = -1/2\) or \(m_s = +1/2\). If the 1s orbital contains only one electron, we have one \(m_s\) value and the electron configuration is written as 1s1 (corresponding to hydrogen). If it is fully occupied, we have two \(m_s\) values, and the electron configuration is 1s2 (corresponding to helium). Visually these two cases can be represented as
As you can see, the 1s and 2s subshells for beryllium atoms can hold only two electrons and when filled, the electrons must have opposite spins. Otherwise they will have the same four quantum numbers, in violation of the Pauli Exclusion Principle.