Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
pushd and popd
Commands

pushd and popd are shell commands that together allow the user to revert to a previous working directory via the command line. They use a stack data structure for directory paths. pushd pushes the working directory path onto the stack and changes to the specified directory, and popd pops the most recent item from the stack and changes directory to the popped value.

Behavior varies if no argument is passed to pushd. On Unix, the command swaps the top two directories on the stack, which toggles between them. On Windows, the command lists the paths in the stack except for the current one.

The commands are widely available as builtin commands in many shells, such as Bash, Command Prompt, PowerShell, C shell, tcsh, 4DOS, Hamilton C shell, KornShell, and FreeCOM.

The stack of directory paths can be displayed via the dirs Unix command or Get-Location -stack PowerShell command. The working directory is at the top of the stack.

The first Unix shell to provide a directory stack was Bill Joy's C shell. The syntax for pushing and popping directories is essentially the same as that used now.

We don't have any images related to pushd and popd yet.
We don't have any YouTube videos related to pushd and popd yet.
We don't have any PDF documents related to pushd and popd yet.
We don't have any Books related to pushd and popd yet.
We don't have any archived web articles related to pushd and popd yet.

Examples

Unix-like

[user@server /usr/ports] $ pushd /etc /etc /usr/ports [user@server /etc] $ popd /usr/ports [user@server /usr/ports] $

Command Prompt and ReactOS

C:\Users\root>pushd C:\Users C:\Users>popd C:\Users\root>

See also

Further reading

  • Frisch, Æleen (2001). Windows 2000 Commands Pocket Reference. O'Reilly. ISBN 978-0-596-00148-3.
  • McElhearn, Kirk (2006). The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. ISBN 978-0470113851.
Wikibooks has a book on the topic of: Guide to Windows Commands

References

  1. Pushd - change directory/folder - Windows CMD - SS64.com https://ss64.com/nt/pushd.html

  2. Popd - Windows CMD - SS64.com https://ss64.com/nt/popd.html

  3. Microsoft TechNet Pushd article https://technet.microsoft.com/en-us/library/bb490978.aspx

  4. Microsoft TechNet Popd article https://technet.microsoft.com/en-us/library/bb490969.aspx

  5. Bash Reference Manual: Directory Stack Builtins http://ftp.gnu.org/old-gnu/Manuals/bash-2.05a/html_node/bashref_73.html

  6. FreeCOM - FreeDOS http://wiki.freedos.org/wiki/index.php/FreeCOM

  7. Chapter 14 – 14.6 The Shells' pushd and popd Commands http://docstore.mik.ua/orelly/unix/upt/ch14_06.htm

  8. man tcsh "TCSH(1)". Archived from the original on 2014-03-10. Retrieved 2014-11-03. https://web.archive.org/web/20140310014443/http://unixhelp.ed.ac.uk/CGI/man-cgi?csh+1