Instantly Jump to Parent Directories with `cd -`
Quick Tip
Instantly Jump to Parent Directories with `cd -`
Challenge: You’ve navigated deep into a directory structure and need to quickly return to your previous working directory, but you don’t want to type the full path.
The Solution: Use the `cd -` command.
cd -
Why it works: The shell maintains a special variable `$OLDPWD` which stores the path of your previous working directory. The `cd -` command is a shortcut that effectively reads this variable and changes your directory to that location.
Pro-Tip: Combine `cd -` with `pushd` and `popd` for a more robust directory history stack. For example, `pushd /path/to/new/dir` changes directory and adds the new path to the stack, while `popd` returns you to the previous directory on the stack.
Linux Tips & Tricks | © ngelinux.com | 6/7/2026
