Electric field due to a line of charge While deriving the formula for electric field due to an infinitely long wire of uniform charge density using Gauss's law we assume that this field has cylindrical symmetry and there is no component of field along the axis.But how do we know that the field has cylindrical symmetry and there is no component of field along the axis.Why can't there be an axial component of field and what happens if we have a wire of finite length? How does the situation differ from the earlier case?
 A: You don't have to assume there is no axial component - it will become apparent when you do the derivation.
Let us assume, without loss of generality, that the line of charge extends in the $X$ direction. Now let us look at the electric field at a point $P$ due to a small line element $dx$, where there is a charge density $\rho$ per unit length. Without loss of generality we can put $P$ at the origin, and look at the wire which is displaced a distance $y$.
Now we can write the expression for the $E_x$ and $E_y$ fields at $P$ due to this element:
$$dE_x = \frac{1}{4\pi\epsilon_0} \frac{\rho dx}{r^2} \frac{x}{r}\\
dE_y = \frac{1}{4\pi\epsilon_0} \frac{\rho dx}{r^2} \frac{y}{r}$$
Writing $r=\sqrt{x^2+y^2}$ and integrating for a wire from $x=a$ to $x=b$ this becomes:
$$E_x = \int_a^b \frac{1}{4\pi\epsilon_0} \frac{\rho~ x~dx}{\left(x^2+y^2\right)^{3/2}}\\
E_y = \int_a^b \frac{1}{4\pi\epsilon_0} \frac{\rho~ y~dx}{\left(x^2+y^2\right)^{3/2}}$$
I will leave you to think about the details - but note that since the expression for $E_x$ is odd in $x$, any integral with symmetrical limits ($a=-b$) will be zero.
A more formal approach (formulated in a general case) can be found at this link. The integral shown there gives you the behavior in terms of the angles between the wire, and the lines connecting the ends of the wire to the point of interest; again, this shows the symmetric nature of the problem; and since these angles will tend to ± $\pi/2$ when the wire becomes infinitely long, the component along the wire will indeed disappear.
A: In the finite case, Maxwells equations need to be solved for a charge density which only extends over a finite length. Depending on the length of the wire, you might mostly see effects on the top and bottom of the wire or, for a small wire, the whole field will look nothing much like the one of the infinitely long wire. The field will however still have rotational symmetry because the problem has rotational symmetry.
In the infinite long wire case, the field also has translational symmetry. This can be seen quite easily, actually. The Poisson equation is:
$$ \Delta \phi = \rho/\varepsilon_0 $$
Now we know that $\rho$ remains invariant under translations along an axis, let us call it the $z$-axis. Further we know that $\Delta$ is also translation-invariant. In the translated frame,
$$ \Delta'\phi' = \rho'/\varepsilon_0 $$
But I have just argued that $\Delta' = \Delta$ and $\rho'=\rho$ - thus $\phi'$ obeys the same differential equation as $\phi$. Thus, $\phi$ cannot depend on $z$ and the field ($\vec{E}=-\nabla\phi$) cannot have a component along the $z$-axis.
We can make the same kind of argument, in both cases, for rotational symmetry too.
A: Infinitely long wire:
Suppose you choose to measure the field at the origin. If you take field generated at the origin by a point at $-L$ on the wire, you will have a field with radial and axial components.
But when you take the field generated by the symmetric point $L$, the axial components will cancel, and you will have a radial electric field. Since the wire is infinitely long, this will be true fr any point where you want to measure the field.
About the cylindrical symmetry, if you observe the wire from any point, and rotate the wire along its axis, the wire will always be the same for the observer, that's why. And there is no angular field becaus charges always produce radial fields, so think of the distribution of charges in a wire, how could they produce an angular component? 
Finite wire
If you wire is of size $L$, the argument above is valid only at the middle point. Otherwise you will have axial components of electric field (wich can be calculated with Gauss's Law)
A: 
But how do we know that the field has cylindrical symmetry


The above picture shows 3 infinitely long line of charge with each line of charge having a point marked as A, B, C which  are equidistant from its corresponding line of charge. A and B are in the same direction and C is in a different direction.
Imagine yourself in a world where only you and the line of charge exists. Can you distinguish between the points A, B? The point B appears to be slightly shifted down.
If you go to point A, you will find the point A to be a distance 'r' away from the line of charge and you see infinity to your left as well right. 
If you go to point B, you will find the point B to be a distance 'r' away from the line of charge and you see infinity to your left as well right.
Of course, they are different points in space but is it possible for the line of charge to distinguish between the two points? There is no difference between the two points for the line of charge and hence all physical properties of point A must be identical to that of point B.
Did we say that point B is exactly 'x' distance downwards from point A? We didn't! The point B was chosen arbitrarily. Therefore, the conclusion which was drawn above for properties of point A and B can be extended to all points which are a distance 'r' from the line of charge. This means that the properties of all the points which are equidistant from the line of charge and point along the same direction from the line of charge will have EXACTLY identical properties.
In the case of an electric field, the direction is such that it always points away from the line of charge (in case the line of charge is positive). 
Why? Let us assume that the electric field wasn't exactly away from the line of charge and it bent towards the left. Now ask, why did you choose left? Why not right? ... Therefore, the direction of electric field must always be along the line joining the line of charge and the point in space.
Now consider point B and C. They are equidistant from their corresponding line of charge but are in different directions. Go to point B and measure the electric field. Then go to point C and measure the electric field. Do you find any difference? You will find the electric field's direction is away from the line of charge and the electric field's magnitude to be equal (because you cannot distinguish between the point B and point C - imagine a line of charge and go to point B and point C, how are you going to distinguish between the two points? You see the same line of charge in front of you at any point)
Hence, the electric field's magnitude is identical for all the points which are equidistant from the line of charge and the electric field's direction  is always away from the line of charge.

Why can't there be an axial component of field

The same kind of reasoning done in the above explanation will help you answer this question. In which direction should the axial field be in? Upwards or downwards? If you choose either one of them then ask yourself why not the other way? The line of charge is always fair and does not ill-treat different points. The only way to solve the problem is to have no axial field at all (the direction is no more an issue now).

what happens if we have a wire of finite length? How does the situation differ from the earlier case?


Let us try to apply the same reasoning as we did in the first explanation. 
Go to point A, you can note down the distance of the point from the ends of the finite wire. Now go to point B, you can note down the distance of the point from the ends of the finite wire.
Are they same? Of course, they are not! One is closer to the foot of the wire and one is a bit above the middle of the wire. There is simply no reason to state that they must have same properties.
Why did the reasoning work for the infinite wire? Every point is an infinite distance away from the both the ends of the wire and hence the argument works.
You can derive the formula for electric field for a finite wire. When consider the limiting case of the wire being infinitly long, your formula for finite wire reduces to the one that of infinite wire which was obtained using Gauss Law.
Why do Gauss Law exam questions always have a symmetry?
The answer is obvious if you look at the formula,
$$\oint{\vec{E}.d\vec{S}} = \frac{q}{\epsilon_o}$$
For a symmetric distribution, you ca always take a surface such as a sphere, cylinder where the electric field is equal everywhere.
If the field is equal everywhere, you can pull the field parameter out of the integral and you will be left with,
$$E\oint d\vec{S} = \frac{q}{\epsilon_o}$$
The problem ends up being a calculation of area problem whose area is extremely easy to calculate (you know a formula for it most of the times).
However, Gauss law is valid even when the charge distribution/gaussian surface is not symmetric but these cases involve a vector integration process which are always terrible, cumbersome, awful, annoying...
A: I'll try to keep it very simple.
Let us first find out the electric field due to a finite wire having uniform charge distribution.
You'll see that the electric field depends only on the charge to length ratio and the angles with the ends of the wire make with the perpendicular to the rod passing through the point P where you are to find the electric field.

Also, when we take the derivation of the infinite wire case using Gauss law, we generally make the assumption that the parallel components of electric field cancel out as the wire extends infinitely on both sides. So, a cylindrical Gaussian surface suits as explained by the other fellows. However, I dont know if the derivation for a finite length wire is possible using Gauss law.
Needless to say, I used Coulomb's law for the derivation.
