The simplest solution will be to write the system in form of \mathbf{X}\mathbf{\beta}=\mathbf{Y}, and then solve it using X^{-1}Y, if X is invertible. Otherwise, if X'X is invertible, you can use (X'X)^{-1}X'Y, else you can use generalized inverse of X'X.
Look at the solve function provided in the base package and ginv of the MASS package.
You may also want to take a look at this: Solving Linear Equations