Using pushd and popd to Manage a Stack of Directories

Learn how to use the pushd and popd commands.

We'll cover the following

The pushd command

The pushd command, short for “push directory,” changes our current working directory and adds it to a directory stack or a list of directories. We can then view this stack or easily jump to an entry in the stack. Try it out. First, we navigate to our home directory.

$ cd

Now, use pushd to switch to the /var folder:

$ pushd /var

Get hands-on with 1200+ tech skills courses.