Effortless Directory Hopping with `pushd` and `popd`

Quick Tip

Effortless Directory Hopping with `pushd` and `popd`

Challenge: Frequently navigating back and forth between several directories can be tedious and involve typing long paths repeatedly.

The Solution: Leverage the `pushd` and `popd` commands to manage a stack of directories.

# Navigate to a new directory and add it to the stack pushd /path/to/new/directory # Later, switch back to the previous directory on the stack popd # View the 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 reversing the `pushd` operation. `dirs` displays the current stack.

Pro-Tip: You can also use `pushd +n` to switch to the n-th directory in the stack, and `popd +n` to remove it.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments