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 just in, or to its immediate parent. Repeatedly typing `cd ../../..` can be tedious.

The Solution: Use the `cd -` command to instantly jump to your previous working directory. For navigating to the immediate parent directory, simply use `cd ..`.

cd -

Why it works: The shell maintains a variable `$OLDPWD` that stores the previous directory. `cd -` is a shortcut that effectively expands to `cd “$OLDPWD”`, taking you back to where you were.

Pro-Tip: Combine `cd -` with `pushd` and `popd` for managing a stack of directories you frequently switch between. `pushd ` adds a directory to the stack and changes to it, while `popd` removes the top directory and returns you to it.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted