Windows pushd / popd equivalent in Linux
Saves your current directory to a stack so you can jump back to it later after navigating elsewhere.
pushd / popd
pushd / popd
pushd / popd
pushd / popd
Overview
What this command does
On Windows, "pushd / popd" is used to save and restore directory location. On Linux, the closest practical mapping shown here is "pushd / popd". Saves your current directory to a stack so you can jump back to it later after navigating elsewhere. This reference is grouped under File Management → File System.
Windows → Linux context
What changes when you use this on Linux?
Same name, different environment
The basic command name pushd is familiar on both platforms, but Linux path rules, quoting, permissions and available options can still change the result.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux filesystem for Windows users.
Practical tasks
Common use cases
Save and restore directory location
Saves your current directory to a stack so you can jump back to it later after navigating elsewhere.
pushd /some/path
Save current dir and go to path
popd
Return to last saved directory
dirs
Show the full directory stack
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
pushd /var/log/nginx
popd
pushd ~/Projects
pushd /etc
dirs -v
Walkthrough
Examples with explanations
# Save your place, go deep, come back
pushd /var/log/nginx # go there, save current dir
(do some work...)
popd # return to where you were
# Stack multiple directories:
pushd ~/Projects
pushd /etc
dirs -v # shows: 0=/etc 1=~/Projects 2=...
popd # back to ~/Projects
Reference
Common options and variations
| Command or option | Use |
|---|---|
pushd /some/path | Save current dir and go to path |
popd | Return to last saved directory |
dirs | Show the full directory stack |
dirs -v | Show stack with index numbers |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
Debian/Ubuntu, Fedora and Arch all use "pushd / popd" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | pushd / popd |
Same command on this distribution. |
| Fedora | same command | pushd / popd |
Same command on this distribution. |
| Arch | same command | pushd / popd |
Same command on this distribution. |
Keep learning