Consider an infinitely long thin straight wire with uniform linear charge density λ. The wire is obviously an axis of symmetry. Suppose we take the radial vector from O to P and rotate it around the wire. The points P, P', P'' so obtained are completely equivalent with respect to the charged wire. This implies that the electric field must have the same magnitude at these points. The direction of electric field at every point must be radial (outward if λ > 0, inward if λ < 0).

The total field at any point P is radial. Finally, since the wire is infinite, electric field does not depend on the position of P along the length of the wire. In short, the electric field is everywhere radial in the plane cutting the wire normally, and its magnitude depends only on the radial distance r. To calculate the field, imagine a cylindrical Gaussian surface, as shown in the Fig. Since the field is everywhere radial, flux through the two ends of the cylindrical Gaussian surface is zero. At the cylindrical part of the surface, E is normal to the surface at every point, and its magnitude is constant, since it depends only on r. The surface area of the curved part is 2πrl, where l is the length of the cylinder.
Flux through the Gaussian surface = flux through the curved cylindrical part of the surface = E × 2πrl
The surface includes charge equal to λl. Gauss’s law then gives

where ˆn is the radial unit vector in the plane normal to the wire passing through the point. E is directed outward if λ is positive and inward if λ is negative.