Effortless Directory Hopping with `cd -`

Quick Tip

Effortless Directory Hopping with `cd -`

Challenge: Frequently switching between two directories and finding yourself needing to quickly return to the previous one can be tedious, requiring you to remember and retype the full path.

The Solution: Use the special hyphen (`-`) argument with the `cd` command to instantly jump back to your previous working directory.

cd -

Why it works: The shell maintains a directory stack that keeps track of your current and previous working directories. `cd -` tells the shell to move to the directory that was previously at the top of this stack.

Pro-Tip: Use `pushd` and `popd` to manage multiple directories on the stack for even more advanced navigation.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments