Changing Directories: pushd and popd

After you master the cd command, you need to learn to move around Unix using the pushd and popd commands. pushd <directoryname> will need to be entered if you want to specify the directory. With the popd command, however, you will not need to specify a directory name.

When changing between directories, these two commands allow you to make good use of the directory stack. The directory stack is a type of data storage that works as follows: Data is added to the top, thus creating the stack, and the most recently added “plate” of data is the first to be removed if requested, because it comes off the top of the stack. To describe this in terms of the pushd and popd commands, data is pushed (pushd) onto the stack ...

Get SAMS Teach Yourself Unix in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.