Banana slugs evolved from snails, and both are classified as Gastropoda. The slugs' deterrent slime permitted them to almost completely abandon the protective but cumbersome shells carried by their snail ancestors. A few predators manage to eat banana slugs despite their defensive production of copious mucus, but the process is disgusting to watch. Some potential diners are deterred by the slime's anesthetic effect.
Banana slugs will consume almost anything, including stinging nettle and poison oak. They love mushrooms. The detritus seen on a slug's tail is simply debris captured by slime. The anus is discretely concealed under the mantle just behind the breathing orifice.
Slug locomotion is very interesting. The photo shows a slug on a vertical pane of glass. It does not not slip off because its slime is thixotropic, meaning that its viscosity is reduced by deformation — the slime is relatively rigid and sticky when stationary, but becomes fluid when sheared by muscular contractions of the foot. Wave-like contractions begin at the tail and speed forward five times faster than the slug moves. (Millipede leg-waves move at twice body speed.) A video can be found at scienceforkids.org.
MIT built a wall-climbing machine that alternately sticks and slides plates upon a layer of artificial slime, but I suspect that slug waves lift up slightly, which would additionally serve to recycle slime toward the head. Place a slug on a pane of glass and decide for yourself. But be prepared to spend some time washing the persistent slime off your hands.
Fellow geologists may notice analogies with stick-slip earthquake mechanisms and with the shaking-induced liquefaction of wet sediments.