  We develop an algebraic theory of supports for $R$-linear codes of fixed
length, where $R$ is a finite commutative unitary ring. A support naturally
induces a notion of generalized weights and allows one to associate a monomial
ideal to a code. Our main result states that, under suitable assumptions, the
generalized weights of a code can be obtained from the graded Betti numbers of
its associated monomial ideal. In the case of $\mathbb{F}_q$-linear codes
endowed with the Hamming metric, the ideal coincides with the Stanley-Reisner
ideal of the matroid associated to the code via its parity-check matrix. In
this special setting, we recover the known result that the generalized weights
of an $\mathbb{F}_q$-linear code can be obtained from the graded Betti numbers
of the ideal of the matroid associated to the code. We also study subcodes and
codewords of minimal support in a code, proving that a large class of
$R$-linear codes is generated by its codewords of minimal support.
