Site icon New Generation Enterprise Linux

Effortless Directory Hopping with `pushd` and `popd`

Quick Tip

Effortless Directory Hopping with `pushd` and `popd`

Challenge: You frequently navigate between a few key directories for your work, and constantly typing `cd` with long paths becomes tedious and error-prone.

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

# Navigate to your project directory pushd ~/projects/my-awesome-app # Do some work... # Quickly jump back to your home directory pushd ~/documents/reports # Do more work... # Jump back to the previous directory (my-awesome-app) popd # Jump back to home directory again popd

Why it works: `pushd` adds the current directory to a stack and then changes to the specified directory. `popd` removes the top directory from the stack and changes to it, allowing you to swiftly return to previously visited locations.

Pro-Tip: Type `dirs` or `d` to view the current directory stack.

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

0 0 votes
Article Rating
Exit mobile version