Gauss's law is able to give the relationship between the electric field at every point on the surface and charge enclosed by that surface. Gauss's law can be used to find the electric field from a given charge distribution (total net charge) and total net charge from a given field if the electric field is uniform on a highly symmetric surface so that the integral \(\int {E\cos \theta {\kern 1pt} dA} \) can be evaluated easily. According to Gauss's law the total electric flux \(\Phi\) through a closed surface is equal to the total charge (net charge) \(q\) enclosed by that surface divided by \(\epsilon_0\). Here \(q\) represents the magnitude of electric charge and inward and outward flux is determined by the sign of \(q\).
\[{\rm{ }}\Phi {\rm{ }} = \int {E\cos \theta {\mkern 1mu} dA} = \frac{q}{{{\epsilon _0}}} \tag{3} \label{3}\]
We know that the total electric flux produced by a net charge \(q\) through a closed surface is given by the integration \(\int {E\cos \phi {\mkern 1mu} dA} \). Here \({E\cos \theta {\mkern 1mu} }\) is the perpendicular component of electric field through the plane of area \(dA\). The integration \(\int {E\cos \phi {\mkern 1mu} dA} \) can also be defined as \(\int {dA\cos \theta {\mkern 1mu} E} \) where \({dA\cos \theta {\mkern 1mu} }\) is the projection of \(dA\) on a plane perpendicular to the direction of electric field.
As an example we apply Eq. \eqref{3} on a sphere of radius \(r\) which encloses a net charge \(q\) shown in Figure 3. The sphere is symmetric and therefore the electric field is uniform throughout the sphere. Hence, the electric field lines passing through the surface of the sphere are perpendicular to the corresponding area elements \(dA\). So, \(\cos \theta = \cos 0 = 1\) and,
\[\begin{align*} \Phi {\rm{ }} &= \int {EdA} {\rm{ }} = E\int {dA} = EA\\ \quad &= E(4\pi {r^2}) = \left( {\frac{q}{{4\pi \epsilon_0{r^2}}}} \right)(4\pi {r^2}) = \frac{q}{\epsilon_0} \end{align*}\]
This is the expression obtained for a symmetric surface where the electric field is uniform on the surface. You'll see later that Gauss's law is valid for any kind of closed surface where the electric field may not be the same at every point on the surface. Consider two concentric spheres enclosing the same charge \(q\) and we now calculate the electric flux through both of the spheres produced by the same charge. Now we determine the electric flux through the sphere of radius \(r_1\) which can be obtained as,
\[\begin{align*} {\rm{ }}\Phi {\rm{ }} &= E\int {dA} = EA = E(4\pi {r_1}^2)\\ {\rm{or,}}\quad \Phi &= \left( {\frac{q}{{4\pi {\epsilon_0}{r_1}^2}}} \right)(4\pi {r_1}^2) = \frac{q}{{{\epsilon_0}}} \end{align*}\]
And the electric flux through the concentric sphere of radius \({{r}_{2}}\) is,
\[\begin{align*} {\rm{ }}\Phi {\rm{ }} &= E\int {dA} = EA = E(4\pi {r_2}^2)\\ {\rm{or,}}\quad \Phi &= \left( {\frac{q}{{4\pi {\epsilon_0}{r_2}^2}}} \right)(4\pi {r_2}^2) = \frac{q}{{{\epsilon_0}}} \end{align*}\]
So the electric flux is independent of the size of the surface enclosing the charge but only depends on the magnitude of charge enclosed by the surface. Suppose that \(r_2=2r_1\). Now the electric field at the surface of the sphere of radius \(r_2\) decreases by a factor of \(\frac{1}{4}\) which is \(k\frac{q}{{{r_2}^2}} = k\frac{q}{{{{(2{r_1})}^2}}} = k\frac{q}{{4{r_1}^2}}\). On the other hand the surface area of the sphere increases by a factor of 4 that is \(4\pi {r_2}^2 = 4\pi {(2{r_1})^2} = 4(4\pi {r_1}^2)\). So the total electric flux through both of the surfaces remain the same.
The Gauss's Law is still true even if the enclosing surface is not symmetric; it means the electric field may not be the same at every point on the surface. It is because we obtain Gauss Law from the integration in Eq. \eqref{3} in which we determine the electric flux. As already noted the value \({dA\cos \theta {\mkern 1mu} }\) is the projection of \(dA\) which is always perpendicular to the electric field and for any kind of closed surface the projection is alwyas the spherical surface. So, Gauss's Law is still valid for irregular surface. So a general form of Gauss's Law can be given as,
\[\Phi {\rm{ }} = \oint {E\cos \theta dA} = \frac{q}{{{\epsilon_0}}} \tag{4} \label{4}\]
The sign of electric flux is determined by the sign of \(q\). A circle in the integral sign in \eqref{4} is a reminder that the integration is always taken over a closed surface. Gauss's Law requires a net charge should be enclosed by a surface and if there are multiple charges enclosed by the surface we determine the net charge and use the Gauss' law. We can determine the electric field from a given charge distribution and charge distribution from the electric field but the integral in \eqref{3} or \eqref{4} is difficult to evaluate for irregular surfaces. So for the highly symmetric closed surface the integral is much easier to evaluate and the result can be obtained easily.
We apply Gauss's law to find the electric field due to a given charge distribution and we can also find the charge distribution from a given electric field if the enclosing surface is symmetric so that the integral \(\Phi {\rm{ }} = \oint {E\cos \theta dA} = \frac{q}{{{\epsilon_0}}}\) can be evaluated easily.
Where are the charges?
The charges always lie on the outer surface of a conductor. When excess charge is added to a conductor the charge always lies at rest on the outer surface of the conductor. This can be explained in terms of the electrostatic situation of the charge. In electrostatic situation the charge remains at rest not in motion.
Since the excess charge added to the conductor is at rest, there shouldn't be any electric field inside the conductor, and if there is any electric field inside the conductor the charge will move which disturbs the electrostatic situation. So, there should not be any electric field inside the conductor, and no electric field means no charge. Which concludes that if there is no charge inside the conductor, there is no electric field which disturbs the electrostatic situation and this is valid only if the charge lies on the outer surface of the conductor.
Let's check this with Gauss's Law. We make a Gaussian surface exactly like the one shown in Figure 1. For the electrostatic situation there shouldn't be any electric field inside the conductor, so there shouldn't be any electric field inside the Gaussian surface which means there does not exist any charge inside the Gaussian surface. Therefore, there is no charge inside the Gaussian surface and it means the charge should lie on the conductor's outer surface.