Effortless Directory Hopping with `pushd` and `popd`

Quick Tip

Effortless Directory Hopping with `pushd` and `popd`

Challenge: Frequently navigating back and forth between multiple directories can be tedious and prone to typos when re-entering paths.

The Solution: Utilize the `pushd` and `popd` commands to manage a directory stack, allowing you to quickly switch between locations.

# To go to a new directory and add it to the stack: pushd /path/to/new/directory # To go back to the previous directory in the stack: popd # To view the current directory stack: dirs 

Why it works: `pushd` adds the current directory to a stack and then changes to the specified directory. `popd` removes the top directory from the stack and changes to it, effectively allowing you to easily cycle through previously visited directories.

Pro-Tip: Use `pushd +N` to swap the current directory with the Nth directory in the stack, and `popd -N` to remove the Nth directory from the stack.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments