Site icon New Generation Enterprise Linux

Quickly Jump to Parent Directories with `cd -`

Quick Tip

Quickly Jump to Parent Directories with `cd -`

Challenge: You’ve navigated deep into a directory structure and need to quickly return to the directory you were in just before the current one.

The Solution: Use the `cd -` command.

cd -

Why it works: The shell keeps track of your current and previous directory in the `PWD` and `OLDPWD` environment variables, respectively. `cd -` efficiently swaps to the directory stored in `OLDPWD`.

Pro-Tip: For managing multiple directory stacks, explore the `pushd` and `popd` commands.

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

0 0 votes
Article Rating
Exit mobile version