Fast command-line navigation using pushd and popd
When navigating around multiple locations in the filesystem, a common practice is to cd to paths you copy and paste. This is not efficient if we are dealing with several locations. When we need to navigate back and forth between locations, it is time consuming to type or paste the path with each cd command. Bash and other shells support pushd and popd to cycle between directories.
Getting ready
pushd and popd are used to switch between multiple directories without retyping directory paths. pushd and popd create a stack of paths-a LastInFirstOut (LIFO) list of the directories we've visited.
How to do it...
The pushd and popd commands replace cd for changing your working directory.
- To push and change a directory to a path, use this command:
~ $ pushd /var/wwwNow the stack contains /var/www ~ and the current directory is changed to /var/www.
- Now, push the next directory path:
/var/www $ pushd /usr/src Now the stack contains /usr/src/var/www ~ and the...