Let's consider a charge \(q\) is distributed uniformly in a line and forms a line of charge and find the electric field at a perpendicular distance from the line of charge. We apply symmetry considerations and use Gauss's law to find the electric field. When you make a Gaussian surface to solve problems using Gauss's law you can make any kind of Gaussian surface either regular or irregular but a trick is that we make the Gaussian surface symmetrical with the charge distribution so that we can easily evaluate the Gauss's law equation (see Figure 1). Here the line of charge has cylindrical symmetry, so we apply the same cylindrical symmetry in our Gaussian surface.
We first determine the electric flux through each ends of the cylinder and then through the curved surface. Finally we get the total electric flux by adding them together. The electric field of the line of charge is radially outward. It is because there is no such thing as the component of electric field parallel to the line of charge or tangent to the curved Gaussian surface or any other component and can not be concluded that the electric field is not radially outward. The charge is distributed uniformly throughout the line or wire, the electric field is uniform.
Since the electric field is radially outward, it is parallel to the ends of the Gaussian cylinder and hence the electric flux through the ends of the cylinder is zero. The electric field due to the line of charge is perpendicular to the curved surface. The total charge enclosed by the Gaussian surface is the liner charge density (charge per unit length) \(\lambda \) multiplied by the length of the Gaussian cylinder \(l\). If the Gaussian cylinder has radius \(r\), the area of the curved surface of the Gaussian surface is \(2\pi rl\). Now the electric field can be determined by using Gauss's law,
\[\begin{align*} E(2\pi rl) &= \frac{{\lambda l}}{{{\epsilon_0}}}\\ {\rm{or, }}\quad E &= \frac{\lambda }{{2\pi {\epsilon_0}r}} = k\frac{{2\lambda }}{r} \tag{10} \end{align*}\]
This expression is the same as the expression of the electric field of an infinite length line of charge without using Gauss's law. This is because we have considered a small portion of the line of charge in our Gaussian cylinder where all the electric field lines are radially outward which satisfies the condition of being the perpendicular distance \(r\) is small enough in comparison to the length of the line of charge (also satisfies the point where we are calculating the Electric field (Gaussian surface) is close enough to the line of charge).