Windows
Linux
File Management
File System
Windows pushd / popd equivalent in Linux
Saves your current directory to a stack so you can jump back to it later after navigating elsewhere.
Windows
→
pushd / popd
Linux equivalents
pushd / popd
pushd / popd
pushd / popd
Overview
What this command does
Saves your current directory to a stack so you can jump back to it later after navigating elsewhere.
Migration tip: These commands work the same in Linux!
pushd saves your spot, popd returns you to it. dirs shows the full directory stack.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
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| 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