Site icon New Generation Enterprise Linux

Instantly Jump to Parent Directories with `cd -`

Quick Tip

Instantly Jump to Parent Directories with `cd -`

Challenge: You’re deep in a directory structure and need to quickly return to the parent directory you were just in, without having to type out the full path.

The Solution: Use the `cd -` command.

cd -

Why it works: The shell keeps track of your current directory (`PWD`) and the previous directory (`OLDPWD`). The `cd -` command is a shortcut that tells the shell to change to the directory stored in `OLDPWD`.

Pro-Tip: For managing multiple previous directories, explore `pushd` and `popd` for a directory stack.

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

0 0 votes
Article Rating
Exit mobile version