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 the previous directory you were in, without having to type the full path again.

The Solution: Use the `cd -` command.

cd -

Why it works: The shell maintains a special variable, `OLDPWD`, which stores the path of the previous working directory. `cd -` is a shortcut that effectively expands to `cd $OLDPWD`.

Pro-Tip: Combine this with `pushd` and `popd` for managing a stack of directories you’ve visited. `pushd dir_name` changes to `dir_name` and adds the current directory to the stack, while `popd` removes the top directory from the stack and changes to it.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments