Quick Tip
Quick Directory History Navigation with `pushd` and `popd`
Challenge: Frequently switching between multiple directories can be cumbersome and involves remembering the full path each time.
The Solution: Utilize `pushd` to add a directory to a stack and `popd` to return to previously visited directories.
# To add a directory to the stack and change to it: pushd /path/to/your/directory # To return to the previous directory in the stack: popd # To view the directory stack: dirs -v
Why it works: `pushd` not only changes your current directory but also adds it to an internal stack. `popd` then removes the most recent directory from the stack and returns you to it, creating a Last-In, First-Out (LIFO) navigation history.
Pro-Tip: Use `pushd +n` to rotate the stack and `popd -n` to remove the nth directory from the stack.
Linux Tips & Tricks | © ngelinux.com | 4/28/2026
