Derivation of random variable for chi-square distribution.

Hello all,
In the chi-square distribution, how is the value of random variable derived. In the textbooks, the random variable is given directly as.

1st equation is for random variable, 2nd value is the test statistic used during inference of variance of a population.

Source: Introduction to Statistical Quality Control by DOUGLAS C. MONTGOMERY