Site icon New Generation Enterprise Linux

Stealthy Directory Navigation with `pushd` and `popd`

Quick Tip

Stealthy Directory Navigation with `pushd` and `popd`

Challenge: You frequently jump between different directories for your tasks, and constantly typing `cd` can be tedious, especially when you need to return to a previous location quickly.

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

# Go to a directory and add it to the stack pushd /path/to/projectA # Do some work in projectA # Go to another directory and add it to the stack pushd /path/to/projectB # Do some work in projectB # Quickly return to the previous directory (projectA) popd # Return to the directory before that (original directory) 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, effectively letting you “pop” back to where you were.

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

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

0 0 votes
Article Rating
Exit mobile version