Effortless Directory Navigation with `cd -`

Quick Tip

Effortless Directory Navigation with `cd -`

Challenge: Frequently jumping back and forth between two directories can be tedious, involving multiple `cd` commands and remembering the previous path.

The Solution: Use `cd -` to instantly return to the previous directory you were in.

cd -

Why it works: The `cd -` command is a shell shortcut that expands to the value of the `$OLDPWD` environment variable, which stores the path of the directory you were in before the last `cd` command.

Pro-Tip: For managing multiple directories you frequently switch between, consider using `pushd` and `popd` to create a directory stack.

Linux Tips & Tricks | © ngelinux.com | 5/6/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments