The polynomial given does not factor (with integer coefficients), but perhaps $3x^3-x^2-3x+1$ was intended. One technique for factoring polynomials with several terms (typically more than 3) is to group terms together and factor a common monomial factor out of each group. In this instance: $\begin{align} 3x^3-x^2-3x+1 &= (3x^3-x^2)+(-3x+1) \\ &= x^2(3x-1)-1(3x-1) \\ &=(x^2-1)(3x-1) \\ &=(x+1)(x-1)(3x-1) \end{align}$ The final step is one of several common factoring patterns—this one is sometimes referred to as a difference of squares: $a^2-b^2=(a+b)(a-b)$.
edit As to how to factor in general, my inclination is to say that you don't. If you pick a polynomial with random integer coefficients, the probability that it factors over the integers is 0. Typically, in textbooks, the factoring problems are common monomial factors, specific factoring patterns (difference of squares, sum/difference of cubes, perfect-square, perfect-cube, etc.), factoring-by-grouping, quadratics, or some other special-case technique (as below).
On a side note, since two other answers have suggested factoring by looking for roots, there are polynomials with integer coefficients that factor over the integers but have no real roots or no rational roots (though I think they must be of degree 4 or greater). For example: $\begin{align} x^4+2x^2+81 &=x^4+18x^2+81-16x^2 \\ &=(x^2+9)^2-(4x)^2 \\ &=(x^2-4x+9)(x^2+4x+9) \end{align}$ (This is an example of a class of such problems [quartics that are quadratics in $x^2$] that I have seen in multiple textbooks where the technique is a sort of "completing the square," but applied to the middle term, followed by a difference-of-squares factoring.)