Some fungi are saprophytes (get their nutrients from dead organic matter). For example, oyster mushrooms (Pleurotus ostreatus), shiitake mushrooms (Lentinula edodes), and common button mushrooms (Agaricus bisporus).
Some fungi are parasitic (get their nutrients from living organisms while causing the host harm). For example, honey mushrooms (Armillaria), Cordyceps mushrooms, and birch polypore (Fomitopsis). Some are even parasites on other fungi like the lobster mushroom (Hypomyces lactiflourum) that is a parasite of Russula and Lactarius mushrooms.