Effortless Directory Hopping with `cd -`

Quick Tip

Effortless Directory Hopping with `cd -`

Challenge: You frequently find yourself navigating back and forth between two directories. Manually typing the full path each time can be tedious and error-prone.

The Solution: Use the `cd -` command to instantly jump to your previous working directory.

cd -

Why it works: The shell maintains a directory stack. `cd -` accesses the top entry of this stack, which represents the directory you were in before your most recent `cd` command.

Pro-Tip: Combine `pushd` and `popd` for managing multiple directories in a stack. `pushd ` adds a directory to the stack and changes to it, while `popd` removes the top directory and returns you to it.

Linux Tips & Tricks | © ngelinux.com | 6/21/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted