There has been tremendous growth in studying nonequilibrium systems in which the individual units are internally driven and are self-mobile. Such dynamics can effectively describe certain biological systems such as run-and-tumble bacteria or crawling cells, as well as non-biological systems such as self-driven colloids or artificial swimmers. These systems are now being grouped into a new class of matter called active matter. They exhibit a wealth of novel nonequilibrium behaviours, such as clustering, flocking, and phase separation. In non-active systems there are numerous examples of collections of interacting particles that can be driven over random and periodic substrates such as vortices in type-II superconductors, colloids on periodic optical lattices, models of friction, and particle flows through porous media. Here we examine the dynamics of active matter systems interacting with random or periodic substrates. We show that active particles can exhibit a number of distinct dynamical phases when moving or driven over random or periodic substrates. We find that in some cases, increasing the activity or the self-propulsion of the particles can increase the transport across the substrate; however, there are also regimes in which increased activity can lead to enhanced pinning or jamming of the systems. For nonactive systems we show that in the presence of random arrays the flow and density become highly heterogeneous. For intermediate activity the flow becomes uniform, and at high activity the flow once again becomes heterogeneous leading to strong clogging effects. In the dense particle limit, we find that active matter systems can show interesting motion of dislocations, grain boundaries and other topological structures distinct from those found in purely thermally driven systems or systems with external drives.