Fungi are heterotrophic and obtain their nutrients, like sugars, nitrogen, and phosphorus, from feeding on living or dead organisms, or thriving in rich organic soil.  Specifically, mushrooms obtain their nutrients by absorbing it through mycelia (multiple connected hyphae) that grows through the substrate.  Substrates can range from wood, to a rotten apple, to living flesh, and even plastics and other surprising materials, but in the case of Coprinopsis atramentaria it will usually be some sort of decaying wood.   At the tips of hyphae, exoenzymes are secreted that break down the surrounding macromolecules into smaller molecules, the hyphae then grow into the newly broken down material and absorb up nutrients through pores in the cell walls.  As humans, we ingest then digest, whereas mushrooms digest then ingest!  Fungi are also aerobic, meaning they require oxygen to live.  Thus, they can't live in soil that is anaerobic for significant periods.  Anaerobic conditions often occur in compact soil, or soil that it waterlogged.

Detritivorous fungi, like Coprinopsis atramentaria, are ecologically important in the fact that they break down dead organic material, preventing a buildup of rotting plant material covering the Earth's surface.  Who wants to trudge through rotting leaves and branches all day!  Fungi does more for us than many people are aware of.

Since you now know the importance of these organisms, learn more about how they reproduce to continue their ecological role here.