Precise control of accelerator optics is essential for the safe and efficient operation of modern colliders such as the LHC at CERN. Beam-based studies are one of the key tools at our disposal to try and understand and improve the dynamics of the LHC, and over its first two operational runs the LHC has hosted an extensive program of studies aimed at the linear and nonlinear optics. This talk will present some highlights of the LHC optics commissioning and MD programs.