Determine the Dimension of $U:=\{A\in\textrm{Mat}(2\times 2,\mathbb{R}):AB=BA\}$ 
Given $B\in \textrm{Mat}(2\times 2,\mathbb{R})$
$B=\begin{bmatrix}
    1       & 1  \\
    0      & 1 
\end{bmatrix}$
Determine the dimension of $U:=\{A\in\textrm{Mat}(2\times 2,\mathbb{R}):AB=BA\}$

I already know that $U$ is a Subspace of $\textrm{Mat}(2\times 2,\mathbb{R})$, but I have no idea how I could start with determining a Basis or the dimension other than educated guessing.
 A: Given
$B = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}, \tag 1$
we may write $B$ as
$B = I + N, \tag 2$
where
$N = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}; \tag 3$ 
then we have
$AB = BA \Longleftrightarrow A(I + N) = (I + N)A \Longleftrightarrow A + AN = A + NA \Longleftrightarrow AN = NA; \tag 4$
setting
$A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}, \tag 5$
we compute
$AN =  \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & a \\ 0 & c \end{bmatrix}, \tag 6$
and
$NA = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} a & b \\ c & d \end{bmatrix} =  \begin{bmatrix} c & d \\ 0 & 0 \end{bmatrix}; \tag 7$
comparing (6) and (7) we see we must have 
$c = 0, \; a = d; \tag 8$
$b$ is apparently unconstrained; thus $A$ takes the form 
$A = \begin{bmatrix} a & b \\ 0 & a \end{bmatrix} = aI + bN; \tag 9$
we have shown that the form (9) is a necessary condition for $AB = BA$; it is clear it is also sufficient, since the matrices $N$ and $I$ commute, $NI = N = IN$:
$AB = (aI + bN)(I + N) = aI + aN + bN + bN^2 = aI + (a + b)N, \tag{10}$
$BA = (I + N)(aI + bN) = aI + bN + aN + bN^2 = aI + (a + b)N, \tag{11}$
where we have used the fact $N^2 = 0$ in (10)-(11).
It follows that $I$ and $N$ form a basis for $U$, and that
$\dim U = 2. \tag{12}$
A: Standard tricks are to look at standard matrices such as $I$, and look at
matrices composed of outer products of eigenvectors.
So, we see that $I \in U$. Note that $B e_1 = e_1$, and so $e_1 e_1^T \in U$.
The following are just 'educated' guesses:
If we choose $P$ to be the non identity permutation matrix, we see that $P \notin U$.
Note also that $e_2 e_2^T \notin U$ and this does not lie in the $\operatorname{sp} \{I,P\}$.
The only choices for dimension are $0,1,2,3,4$.
