🐧 pushd Command Guide (Linux Directory Stack)

🐧 pushd Command Guide (Linux Directory Stack)
Operating System(s)

The pushd command lets you switch directories while saving your current location to a stack. It works with popd and dirs to manage directory history more efficiently than cd.

▶️ Basic Usage

Go to a directory and save current one

 

pushd /var/log

 

✔ Moves to /var/log
✔ Saves previous directory to the stack

🔄 Switch Between Directories

Toggle between last two directories

 

pushd

 

✔ Quickly jumps back and forth

📚 View Directory Stack

 

dirs

 

Example output:

/var/log /home/user

 

🔙 Return to Previous Directory

 

popd

 

✔ Removes the top directory from the stack
✔ Returns you to the last location

🧪 Practical Examples

Work in temp folder, then return

 

pushd /tmp
# do work
popd

 

Cycle through multiple directories

 

pushd /etc
pushd /usr
dirs

 

⚙️ Useful Options

Don’t change directory, just add to stack

 

pushd -n /opt

 

Rotate stack

 

pushd +1

 

⚠️ Notes

  • Works in bash, zsh, and similar shells
  • Stack resets when terminal closes
  • Faster than repeatedly typing long paths

🧠 When to Use pushd

  • Switching between project folders
  • Temporary directory changes
  • Shell scripting workflows

💡 Pro Tip

Use pushd + popd instead of cd when multitasking—it saves time and avoids losing your place.

Force Cache (Faster Mirror)

Linux Commands

Files

tar · pv · cat · tac · chmod · grep ·  diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm · scp · gzip · chattr · cut · find · umask · wc · tr · hash  · compgen

Processes

alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg · pidof · nohup · pmap

Networking

netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami ·· iptables · ssh-keygen · ufw · arping · firewalld