Leverage `pushd` and `popd` for Effortless Directory Hopping

Quick Tip

Leverage `pushd` and `popd` for Effortless Directory Hopping

Challenge: Frequently switching between multiple directories can be cumbersome, requiring repeated `cd` commands and making it hard to return to previous locations.

The Solution: Use `pushd` and `popd` to manage a directory stack, allowing you to quickly navigate to new directories and easily return to previous ones.

# Navigate to a new directory and add it to the stack pushd /path/to/new/directory # Later, switch back to the previous directory popd # View the directory stack dirs -v

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 reversing the `pushd` operation.

Pro-Tip: You can `pushd` multiple directories in succession and then `popd` through them to quickly revisit each one.

Linux Tips & Tricks | © ngelinux.com | 4/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments