Directory Stack

noun

say it: “dih-REK-tuh-ree STAK” /dɪˈrɛktəri ˈstæk/

A list of folders the shell remembers, newest on top, that you can add to and step back through in order.

What is the directory stack?

The directory stack is a pile of folders the shell remembers, like a stack of plates: the top one is where you are. pushd folder goes to a folder and puts it on top; popd takes the top one off and goes to the folder under it; dirs -v lists the pile with numbers, 0 on top. It saves retyping long paths when you go back and forth between a few folders.

pushd ~/terminal-practice/photo-project/exports/web
popd                 # back where you were
dirs -v

In a sentence

  • “dirs -v listed the directory stack with the folder Sam was in as number 0.”
  • “pushd put the exports folder on top of the directory stack, and popd took Sam back to the beach photos.”

Level: Journeyman · More Unix terms at this level

Updated