The Gauss law states that electric flux passing through any closed surface is equal to the charge enclosed by that surface divided by permittivity of vacuum.
By symmetry, the magnitude of the electric field will be the same at all points on the curved surface of the cylinder and directed radially outward. →E and →ds are along the same direction.
Now here we have the two surfaces, one curved and other the plane caps,
First, the flux through the curved surface,
∮→E⋅→ds=qinϵ0
E(2πrl)=λl/ϵ0
E=λ2πrϵ0
Now due to the plane caps,
The angle between →E and →ds is 90,
so the flux through that part is zero
so, Total flux through the closed surface is,
E=λ2πrϵ0