  The development of numerical N -body simulations have allowed to study
formation process and evolution of galaxies at different scales. This paper
presents the fundamental concepts of N-body systems applied to the cosmological
evolution of the $\Lambda$-Cold Dark Matter ($\Lambda$CDM) model. In order to
perform structure formation in the Universe, we provide an introduction to the
basic equations and their implementation on the GADGET-2 software. We also
present a simple guide to modify this code. First, we briefly describe the dark
matter in the Universe as well as the theoretical and experimental basis of the
$\Lambda$CDM model. Then, we focus on the simulation codes and provide the
equations that govern most of the N-body simulations to model the dark matter.
We describe the Smoothed Particle Hydrodynamics method used for simulating the
gas, star dynamics and structure formation in these simulations. Then,
cautiously, we guide the reader to the installation of GADGET-2 on a
Linux-based computer, as well as to carry out a couple of examples to operate
the code. Finally, by using a computational cluster, we show several results of
a large structure simulation, analyse the outputs to display the matter power
spectrum, and compare the outcome with theoretical predictions.
