| pushd & popd | |
|---|---|
| Original author | Bill Joy |
| Developers | Variousopen-source andcommercial developers |
| Operating system | Unix,Unix-like,DOS,Windows,ReactOS |
| Platform | Cross-platform |
| Type | Command |

pushd andpopd areshellcommands that together allow the user to revert to a previousworking directory via the command line. They use astackdata structure for directory paths.pushd pushes the working directory path onto the stack and changes to the specified directory, andpopd pops the most recent item from the stack and changes directory to the popped value.[1][2][3][4]
Behavior varies if no argument is passed topushd. 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 asbuiltin commands in many shells, such asBash,[5]Command Prompt,PowerShell,C shell,tcsh,4DOS,Hamilton C shell,KornShell, andFreeCOM.[6]
The stack of directory paths can be displayed via thedirs Unix command orGet-Location -stack PowerShell command. The working directory is at the top of the stack.
The firstUnix shell to provide a directory stack was Bill Joy'sC shell.[citation needed] The syntax for pushing and popping directories is essentially the same as that used now.[7][8]
[user@server /usr/ports] $pushd/etc/etc /usr/ports[user@server /etc] $popd/usr/ports[user@server /usr/ports] $
C:\Users\root>pushd C:\UsersC:\Users>popdC:\Users\root>