Effortless Directory Navigation with `pushd` and `popd`
Quick Tip
Effortless Directory Navigation with `pushd` and `popd`
Challenge: Constantly switching between directories can lead to confusion and wasted time re-navigating back to previous locations.
The Solution: Utilize the `pushd` and `popd` commands to manage a directory stack.
# Push a directory onto the stack and change to it pushd /path/to/new/directory # Later, switch back to the previous directory on the stack popd # View the current 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: Use `pushd +N` to switch to the Nth directory on the stack without removing it, and `popd -N` to remove the Nth directory from the stack.
Linux Tips & Tricks | © ngelinux.com | 4/30/2026
