Forrest logo
tool overview
On this page you find all important commands for the CLI tool pushd. If the command you are looking for is missing please ask our AI.


The pushd command is a command line tool used for navigating directories in a more efficient manner. When executed, it allows you to switch between directories while maintaining a stack-like behavior.

Upon executing pushd, it temporarily saves your current directory, allowing you to navigate to a different directory effortlessly. The current directory is then added to a stack of saved directories.

Each time you execute pushd followed by a directory name, it changes your working directory to the specified directory while also saving your previous directory onto the stack.

The saved directory stack can be accessed and managed using the popd command. When popd is executed, it removes the top directory from the stack and changes your working directory back to it.

By utilizing the pushd and popd commands together, you can navigate back and forth between directories in an organized manner, without needing to remember long directory paths or unnecessarily typing them repeatedly.

The pushd command is particularly useful for scripts and automation, where changing directories frequently is required.

Pushd can also be used with other directory-related commands such as cd (change directory) and dirs (display directory stack) to further enhance navigation capabilities.

If pushd is executed without any arguments, it will switch the top two directories of the stack.

The inverse of pushd is the cd command, which changes the current directory without saving the previous directory onto the stack.

Overall, pushd is a powerful command line tool that simplifies directory navigation, allowing you to switch between directories efficiently and manage a stack of saved directories effortlessly.

List of commands for pushd:

  • pushd:tldr:015c7 pushd: Switch to directory and push it on the stack.
    $ pushd ${path-to-directory}
    try on your machine
    explain this command
  • pushd:tldr:27e94 pushd: Switch first and second directories on the stack.
    $ pushd
    try on your machine
    explain this command
  • pushd:tldr:f2cc0 pushd: Rotate stack by making the 5th element the top of the stack.
    $ pushd +4
    try on your machine
    explain this command
tool overview