Travel is a feature in some NetHack ports that allows one to move quickly along any already explored path on the current level. NetHack uses a shortest-path algorithm to find a safe route to the destination, which is then carried out quickly. Your travel will be interrupted if something sufficiently "interesting" happens, as with the g command.
Travel is activated using the underscore _ key, then selecting a destination as for far look. Some ports allow travel to be activated by mouse-clicking (or touching with a touch-screen) on the destination.
Due to a bug, sometimes the travel command can get stuck plotting a path past certain dungeon features, such as boulders in Sokoban. This bug is marked as fixed.