This paper deals with the basics of cryocoolers and related thermodynamic systems. The treatment is based on the first and second law of thermodynamics for inhomogeneous, open systems using enthalpy flow, entropy flow, and entropy production. Various types of machines, which use an oscillating gas flow, are discussed such as: Stirling refrigerators, GM coolers, pulse-tube refrigerators, and thermoacoustic coolers and engines. Furthermore the paper deals with Joule-Thomson and dilution refrigerators which use a constant flow of the working medium.