Site icon New Generation Enterprise Linux

Effortless Directory Hopping: `pushd` and `popd`

Quick Tip

Effortless Directory Hopping: `pushd` and `popd`

Challenge: Frequently switching between multiple directories can be tedious, involving repeated `cd` commands and remembering complex paths.

The Solution: Use the `pushd` and `popd` commands to manage a directory stack.

# Go to a new directory and add it to the stack pushd /path/to/your/project # Do some work here # Switch back to the previous directory popd # To see the directory stack dirs 

Why it works: `pushd` adds the current directory to a stack and then changes to the new directory. `popd` removes the top directory from the stack and changes to it. This creates a history of directories you can easily navigate back to.

Pro-Tip: Use `pushd +N` to jump to the Nth directory in the stack, and `popd +N` to remove the Nth directory from the stack.

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

0 0 votes
Article Rating
Exit mobile version