I found myself working on this same problem (for homework), and I think I've written a fairly detailed solution. So I will post it here, in case it is helpful to anyone else.

Let $\mathfrak{g}$ be a 1-dimensional Lie algebra, and let $\{E_1\}$ be a basis for $\mathfrak{g}$. Then for any two vector fields $X,Y\in\mathfrak{g}$, we have $X=aE_1$ and $Y=bE_1$, for some $a,b\in\mathbb{R}$. Thus,
$$[X,Y]=[aE_1,bE_1]=ab[E_1,E_1]=0$$
for all $X,Y\in\mathfrak{g}$. Therefore, the only 1-dimensional Lie algebra is the trivial one. The map
$$\varphi:\mathfrak{g}\rightarrow\mathfrak{gl}(2,\mathbb{R})$$
$$\varphi:aE_1\mapsto
\left(\begin{array}{ll}
a&0\\
0&0
\end{array}\right)$$
is a Lie algebra homomorphism, since
$$\varphi([aE_1,bE_1])=\varphi(0)=\left(\begin{array}{ll}
0&0\\
0&0
\end{array}\right)\mbox{, and}$$
$$[\varphi(aE_1),\varphi(bE_1)]=\left(\begin{array}{ll}
a&0\\
0&0
\end{array}\right)\left(\begin{array}{ll}
b&0\\
0&0
\end{array}\right)-\left(\begin{array}{ll}
b&0\\
0&0
\end{array}\right)\left(\begin{array}{ll}
a&0\\
0&0
\end{array}\right)$$
$$=\left(\begin{array}{ll}
0&0\\
0&0
\end{array}\right).$$
Thus, $\mathfrak{g}$ is isomorphic to the (abelian) Lie subalgebra
$$\varphi(\mathfrak{g})=\left\{\left(\begin{array}{ll}
a&0\\
0&0
\end{array}\right)\in\mathfrak{gl}(2,\mathbb{R}):a\in\mathbb{R}\right\}\subset\mathfrak{gl}(2,\mathbb{R}).$$

Now let $\mathfrak{h}$ be a 2-dimensional Lie algebra, and let $\{E_1,E_2\}$ be a basis for $\mathfrak{h}$. Then for any two vector fields $X,Y\in\mathfrak{h}$, we have $X=aE_1+bE_2$ and $Y=cE_1+dE_2$, for some $a,b,c,d\in\mathbb{R}$. Thus,
$$\begin{array}{ll}
[X,Y]&=[aE_1+bE_2,cE_1+dE_2]\\
&=a[E_1,cE_1+dE_2]+b[E_2,cE_1+dE_2]\\
&=ac[E_1,E_1]+ad[E_1,E_2]+bc[E_2,E_1]+bd[E_2,E_2]\\
&=(ad-bc)[E_1,E_2].
\end{array}$$

If $[E_1,E_2]=0$, then we have the trivial 2-dimensional Lie algebra. The map
$$\varphi:\mathfrak{h}\rightarrow\mathfrak{gl}(2,\mathbb{R})$$
$$\varphi:aE_1+bE_2\mapsto
\left(\begin{array}{ll}
a&0\\
0&b
\end{array}\right)$$
is a Lie algebra homomorphism, since
$$\varphi([aE_1+bE_2,cE_1+dE_2])=\varphi(0)=\left(\begin{array}{ll}
0&0\\
0&0
\end{array}\right)\mbox{, and}$$

$$[\varphi(aE_1+bE_2),\varphi(cE_1+dE_2)]=\left(\begin{array}{ll}
a&0\\
0&b
\end{array}\right)\left(\begin{array}{ll}
c&0\\
0&d
\end{array}\right)-\left(\begin{array}{ll}
c&0\\
0&d
\end{array}\right)\left(\begin{array}{ll}
a&0\\
0&b
\end{array}\right)$$
$$=\left(\begin{array}{ll}
0&0\\
0&0
\end{array}\right).$$Furthermore, this map is faithful (injective). Thus, $\mathfrak{h}$ is isomorphic to the (abelian) Lie subalgebra
$$\varphi(\mathfrak{h})=\left\{\left(\begin{array}{ll}
a&0\\
0&b
\end{array}\right)\in\mathfrak{gl}(2,\mathbb{R}):a,b\in\mathbb{R}\right\}\subset\mathfrak{gl}(2,\mathbb{R}).$$

If $[E_1,E_2]\neq0$, then set $E_3=[E_1,E_2]$. Then for all $X,Y\in\mathfrak{h}$ we have $[X,Y]=\lambda E_3$ for some $\lambda\in\mathbb{R}$. In particular, for any $E_4\in\mathfrak{g}$ such that $E_4$ and $E_3$ are linearly independent, we have $[E_4,E_3]=\lambda_0 E_3$. Replacing $E_4$ with $1/\lambda_0 E_4$, we now have a basis $\{E_4, E_3\}$ for $\mathfrak{g}$ such that $[E_4, E_3]=E_3$. The map
$$\varphi:\mathfrak{h}\rightarrow\mathfrak{gl}(2,\mathbb{R})$$
$$\varphi:aE_4+bE_3\mapsto
\left(\begin{array}{ll}
a&b\\
0&0
\end{array}\right)$$
is a Lie algebra homomorphism, since
$$\varphi([aE_4+bE_3,cE_4+dE_3])=\varphi((ad-bc)E_3)=\left(\begin{array}{ll}
0&ad-bc\\
0&0
\end{array}\right)\mbox{, and}$$

$$[\varphi(aE_4+bE_3),\varphi(cE_4+dE_3)]=\left(\begin{array}{ll}
a&b\\
0&0
\end{array}\right)\left(\begin{array}{ll}
c&d\\
0&0
\end{array}\right)-\left(\begin{array}{ll}
c&d\\
0&0
\end{array}\right)\left(\begin{array}{ll}
a&b\\
0&0
\end{array}\right)$$
$$=\left(\begin{array}{ll}
0&ad-bc\\
0&0
\end{array}\right).$$Furthermore, this map is faithful (injective). Thus, $\mathfrak{h}$ is isomorphic to the (non-abelian) Lie subalgebra
$$\varphi(\mathfrak{h})=\left\{\left(\begin{array}{ll}
a&b\\
0&0
\end{array}\right)\in\mathfrak{gl}(2,\mathbb{R}):a,b\in\mathbb{R}\right\}\subset\mathfrak{gl}(2,\mathbb{R}).$$