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 return to the parent directory you were just in, without having to type out the full path or navigate up multiple levels.

The Solution: Use the `cd -` command.

cd -

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

Pro-Tip: Combine this with `pushd` and `popd` for a powerful directory stack management system. `pushd` adds the current directory to the stack and changes to a new one, while `popd` removes the top directory from the stack and changes to it.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments