Seamlessly Jump Between Parent Directories
Quick Tip
Seamlessly Jump Between Parent Directories
Challenge: You’re deep in a directory structure and need to quickly jump back to the parent directory or navigate between recently visited directories without retyping lengthy paths.
The Solution: Utilize the `pushd` and `popd` commands for directory stack management, and `cd -` to instantly return to the previous directory.
# To jump to a new directory and save the current one pushd /path/to/new/directory # To immediately return to the directory you were in before pushd cd - # To see your directory stack dirs # To switch to another directory on the stack (e.g., the second one) popd +1
Why it works: `pushd` adds the current directory to a stack and then changes to the specified directory. `cd -` is a shortcut that refers to the last directory in the stack (the one you were in before the most recent `cd` or `pushd`). `dirs` (or `pushd` without arguments) shows the stack, and `popd` removes directories from the stack, allowing you to efficiently move back and forth.
Pro-Tip: Combine `pushd` and `popd` with `cd -` to create intricate navigation patterns, essentially creating bookmarks for your terminal session.
Linux Tips & Tricks | © ngelinux.com | 6/20/2026
