Molecular mechanisms of lubrication have been studied by high resolution atomic force microscopy (AFM). We will report on two different material system, which exhibit fascinating lubrication properties at the nanometer scale. Graphene is the two-dimensional building block of graphite, a well-known solid lubricant. We will report how friction and the molecular structure of a liquid lubricant oil change at the steel interface due to the presence of graphene. Ionic liquids are promising materials for lubrication, given their viscosity, low vapor pressure, and electric conductivity. When confined to the nanometer-scale gaps, the structure of ionic liquids becomes ordered in molecular layers. Normal forces oscillate when closing the gap between the confining surfaces. We introduce magnetically actuated dynamic shear force microscopy as a method to measure the shear viscosity of confined ionic liquids.