Instantly Jump to Parent Directories with `cd -`
Quick Tip
Instantly Jump to Parent Directories with `cd -`
Challenge: You’re deep within a directory structure and need to quickly navigate back to the directory you were in immediately before the current one. Manually typing the path can be tedious and error-prone.
The Solution: Use the special hyphen argument with the `cd` command.
cd -
Why it works: The `cd -` command utilizes the shell’s internal mechanism for remembering the previous working directory (stored in the `OLDPWD` environment variable) and instantly switches to it. This is incredibly useful for toggling between two locations.
Pro-Tip: Combine `cd -` with `pushd` and `popd` for managing a stack of directories, allowing you to easily revisit multiple previous locations.
Linux Tips & Tricks | © ngelinux.com | 5/18/2026
