  Let $b,n\in \mathbb{Z}$, $n\geq 1$, and ${\cal D}_1, \ldots, {\cal
D}_{\tau(n)}$ be all positive divisors of $n$. For $1\leq l \leq \tau(n)$,
define ${\cal C}_l:=\lbrace 1 \leqslant x\leqslant n \; : \; (x,n)={\cal
D}_l\rbrace$. In this paper, by combining ideas from the finite Fourier
transform of arithmetic functions and Ramanujan sums, we give a short proof for
the following result: the number of solutions of the linear congruence
$x_1+\cdots +x_k\equiv b \pmod{n}$, with $\kappa_{l}=|\lbrace x_1, \ldots, x_k
\rbrace \cap {\cal C}_l|$, $1\leq l \leq \tau(n)$, is \begin{align*}
\frac{1}{n}\mathlarger{\sum}_{d\, \mid \,
n}c_{d}(b)\mathlarger{\prod}_{l=1}^{\tau(n)}\left(c_{\frac{n}{{\cal
D}_l}}(d)\right)^{\kappa_{l}}, \end{align*} where $c_{d}(b)$ is a Ramanujan
sum. Some special cases and other forms of this problem have been already
studied by several authors. The problem has recently found very interesting
applications in number theory, combinatorics, computer science, and
cryptography. The above explicit formula generalizes the main results of
several papers, for example, the main result of the paper by Sander and Sander
[J. Number Theory {\bf 133} (2013), 705--718], one of the main results of the
paper by Sander [J. Number Theory {\bf 129} (2009), 2260--2266], and also gives
an equivalent formula for the main result of the paper by Sun and Yang [Int. J.
Number Theory {\bf 10} (2014), 1355--1363].
