Quick Tip
Effortless Directory Hopping with `cd -`
Challenge: Frequently switching between your current directory and the previous one can be tedious, involving typing the full path repeatedly.
The Solution: Use the `cd -` command to instantly jump back to your previous working directory.
cd -
Why it works: The shell maintains a special variable (`PWD` and `OLDPWD`) that tracks your current and previous directory. `cd -` effectively swaps these two variables, taking you directly to where you were before.
Pro-Tip: For managing multiple directories, `pushd` and `popd` create a directory stack, allowing you to navigate back and forth through a history of visited locations.
Linux Tips & Tricks | © ngelinux.com | 5/12/2026
