Effortless Directory Hopping with `pushd` and `popd`

Quick Tip

Effortless Directory Hopping with `pushd` and `popd`

Challenge: Constantly switching between multiple directories can be tedious, involving repeated `cd` commands and memorizing paths.

The Solution: Use `pushd` to change directories and automatically save the previous directory to a stack, and `popd` to return to the last saved directory.

# Go to a new directory and save the current one pushd /path/to/new/directory # Perform some operations... # Return to the previous directory popd # To see the directory stack dirs 

Why it works: `pushd` maintains a list (stack) of visited directories, allowing you to easily navigate back and forth between them without retyping paths. This significantly speeds up workflows that involve jumping between different project directories.

Pro-Tip: Use `pushd +n` to jump to the n-th directory in the stack, and `popd -n` to remove the n-th directory from the stack.

Linux Tips & Tricks | © ngelinux.com | 6/5/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted