Magnetic properties of nanomagnetic and biomagnetic systems are investigated using cantilever magnetometry. In the presence of a magnetic field, magnetic films or particles deposited at the free end of a cantilever give rise to a torque on the mechanical sensor, which leads to frequency shifts depending on the applied magnetic field. From the frequency response, the magnetic properties of a magnetic sample are obtained. The magnetic field dependences of paramagnetic and ferromagnetic thin films and particles are measured in a temperature range of 5-320 K at a pressure below 10(-6) mbar. We present magnetic properties of the ferromagnetic materials Fe, Co and Ni at room temperature and also for the rare earth elements Gd, Dy and Tb at various temperatures. In addition, the magnetic moments of magnetotactic bacteria are measured under vacuum conditions at room temperature. Cantilever magnetometry is a highly sensitive tool for characterizing systems with small magnetic moments. By reducing the cantilever dimensions the sensitivity can be increased by an order of magnitude.