  When magnetic moments are immersed into the Fermi sea of itinerant electrons,
rich quantum physics emerges. This is relevant for a wide range of materials
including heavy Fermion systems, high temperature superconductors like the
cuprates, but also good metals with magnetic impurities, doped semiconductors
like Si:P close to the metal-insulator transition, 2D materials like graphene
and topological insulators. While each material has its specific properties,
requiring detailed modelling, their electronic properties are to some degree
governed by the competition between Kondo screening and indirect exchange
couplings. In these lecture notes we give an introduction, starting with a
review of formation of magnetic moments, the theory of the Kondo effect for a
single magnetic impurity in a metal host and the derivation of RKKY coupling
between magnetic impurities in a metal host. We review the Doniach diagram and
Kondo lattice physics and give an introduction to a self consistent
renormalization group theory, taking into account Kondo effect and RKKY
coupling between magnetic impurities and review results obtained thereby. We
review the effect of gaps and pseudo gaps on Kondo effect and RKKY couplings,
and on their competition. Especially for dilute concentration of magnetic
moments, disorder effects from randomly distributed impurities result in a
distribution of both Kondo temperatures and RKKY couplings. Then, their
competition becomes an even more complex problem. Moreover, disorder induced
Anderson localization transitions may occur, affecting both Kondo effect and
RKKY coupling severely, and changing their competition. These disorder effects
on the spin competition are introduced and recent results are reviewed. We
conclude with an outlook and list of, in our view, most pressing and
interesting open problems.
