  In this article, we consider systems of linear congruences in several
variables and obtain necessary and sufficient conditions as well as explicit
expressions for the number of solutions subject to certain restriction
conditions. These results are in terms of Ramanujan sums and generalize the
results of Lehmer \cite{DNL13} and Bibak et al. \cite{BBVRL17}. These results
have analogues over $\mathbb{F}_q[t]$ where the proofs are similar, once
notions such as Ramanujan sums are defined in this set-up. We use the recent
description of Ramanujan sums over function fields as developed by Zhiyong
Zheng \cite{ZZ18}. This is discussed in the last section. We illustrate the
formulae obtained for the number of solutions through some examples. Over the
integers, such problems have a rich history, some of which seem to have been
forgotten - a number of papers written on the topic re-prove known results. The
present authors also became aware of some of these old articles only while
writing the present article and hence, we recall very briefly some of the old
work by H. J. S. Smith, Rademacher, Brauer, Butson and Stewart, Ramanathan,
McCarthy, and Spilker \cite{AB26, BS55, PJM76, HR25, KGR44, HJSS61, JS96}.
