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, working on a specific file, and then need to quickly access or modify something in the parent directory. Navigating back manually with `cd ..` can be repetitive, especially if you need to return to your original location later.

The Solution: Utilize the `cd -` command to instantly switch to the previous working directory.

cd -

Why it works: The shell maintains a “previous working directory” variable (often denoted by `OLDPWD`). The `cd -` command is a shortcut that reads this variable and changes your current directory to that location.

Pro-Tip: Combine `cd -` with `pushd` and `popd` for even more powerful directory stack management. `pushd <directory>` adds a directory to the stack and changes to it, while `popd` returns to the previous directory on the stack.

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

0 0 votes
Article Rating
Exit mobile version