Rank of matrix with variable 
$$
 \left( \begin{array}
{ccc}1 & 1 & x \\
1 & x & 1 \\
x & 1 & 1 \\
\end{array} \right) $$
Find the values of $x$ such that the matrix above has rank $1$, $2$ and $3$.

Can I get the matrix to reduced row echelon form, or is there another approach?
 A: There are many methods, one is to compute its characteristic polynomial.
$$\chi(t) = -t^3 + (x+2) t^2 + (x-1)^2 t - (x-1)^2 (2 + x)$$
Then we see we have rank $3$ when $x \neq 1, -2$, rank $2$ when $x = -2$ and rank $1$ when $x = 1$.
A: Option one: row echelon form with contingencies: avoid doing anything which requires a decision, for instance dividing by a possibly zero scalar.  You might get
\begin{equation}
\begin{pmatrix}
1&1&x\\
0&x-1&1-x\\
0&0&-(x+2)(x-1)\\
\end{pmatrix}
\end{equation}
From this, one may see that if $x\neq 1,-2$ then the matrix is full-rank.  If $x=-2$, then it has rank $2$, and if if $x=1$, then it is rank $1$.  For these latter deductions, just substitute and complete the row reduction.
Option two: nullity as Sylvester knew it.  If the $(d-1)$th minors of the matrix all vanish, and at least one $d$th minor does not, then the nullity of the matrix is $d$, so then the matrix has rank $3-d$.
The $0$th minor is the determinant itself, $-(x-1)^2(x+2)$, which vanishes when $x=1,-2$, so the rank is $3$ otherwise (when $x\neq 1,-2$).
The $1$st minors are all either $\pm(1-x)$ or $1-x^2$, which all vanish exactly when $x=1$, so the rank is $2$ otherwise (when $x=-2$).
The $2$nd minors are the entries of the matrix, which never simultaneously vanish, so the rank is $1$ when $x=1$.
A: Hint. Compute the determinant by using Sarrus' rule. You will find a third degree polynomial which has $1$ as a root (for $x=1$ the matrix has rank $1$). If the determinant is not zero then the rank is $3$. Then consider the case when the determinant is zero.
P.S. The determinant is $3x-x^3-2=-(x-1)^2(x+2)$. Therefore for $x\not in \{1,-2\}$ the rank is $3$. If $x=1$ then the rank is $1$. For $x=-2$ the matrix is
$$\left(\begin{array}{ccc}1 & 1 & 2 \\
1 & 2 & 1 \\
2 & 1 & 1 \\
\end{array} \right)$$
which has rank $2$ because the minor $\left(\begin{array}{cc}1 & 1\\
1 & 2
\end{array} \right)$ has anon-zero determinat. 
