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 within a directory structure and need to quickly return to the parent directory you were just in, or perhaps several directories back. Manually typing `cd ../../..` can be tedious and error-prone.

The Solution: The `cd -` command is your shortcut.

cd -

Why it works: The shell maintains a directory stack, and `cd -` toggles between your current directory and the previous working directory. This is incredibly handy for quickly switching back and forth between two locations.

Pro-Tip: Use `pushd` and `popd` to manage a deeper directory stack, allowing you to jump between multiple previously visited directories. For example, `pushd /path/to/new/dir` adds the new directory to the stack, and `popd` takes you back to the previous one.

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

0 0 votes
Article Rating
Exit mobile version