Crawling using muscular waves is observed in many species, including planaria, leeches, nemertea, aplysia, snails, chitons, earthworms and maggots. Contraction or extension waves propagate along the antero-posterior axis of the body as the crawler pushes the ground substratum backward. However, the observation that locomotory waves can be directed forward or backward has attracted much attention over the past hundred years. Legged organisms such as centipedes and millipedes exhibit parallel phenomena; leg tips form density waves that propagate backward or forward. Mechanical considerations reveal that leg-density waves play a similar role to locomotory waves in limbless species, and that locomotory waves are used by a mechanism common to both legged and limbless species to achieve crawling. Here, we report that both mode switching of the wave direction and friction control were achieved when backward motion was induced in the laboratory. We show that the many variations of switching in different animals can essentially be classified in two types according to mechanical considerations. We propose that during their evolution, limbless crawlers first moved in a manner similar to walking before legs were obtained. Therefore, legged crawlers might have learned the mechanical mode of movement involved in walking long before obtaining legs.