How to Find a Finite-Difference Matrix

I have read several websites trying to explain finite-differential equations, but I haven't been able to find one that explains how it's put into the matrix form.

$f(x) = -\frac{d^2u}{dx^2}$ where $u(0) = 0$ and $u(1) = 0$ becomes

$\begin{bmatrix} 2 & -1 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 \\ 0 & -1 & 2 & -1 & 0 \\ 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & -1 & 2 \end{bmatrix}$

multiplied by one column of values between $u_1$ to $u_5$ is equal to

-