Linux command line navigation tips: the basics of pushd and popd commands

In the first part of this series, we focused on the command line navigation aspect in Linux by discussing the usage of the cd – command. Some other related points/concepts were also discussed. Taking the discussion further, in this article, we will be discussing how you can have a faster navigation experience on the Linux command line using the pushd and popd commands.

The basics of pushd and popd commands – To better understand what exactly pushd and popd commands do, let’s first discuss the concept of stack. Imagine an empty area on your kitchen slab, and now imagine a set of plates that you want to keep there. What will you do? Simple, keep them one over the other.

So at the end of the whole process, the first plate that you kept on the slab ends being the last plate in the pile, and the last plate that you had in your hand ends up being the first plate in the pile. Now, when you require a plate, you pick the one which is at the top of the pile, use it, and then pick the next one when required.

Similar is the concept of pushd and popd commands. There’s a directory stack on your Linux system where you can pile up directory paths for future use. You can quickly see the contents of the stack at any point in time using the dirs command.

Here’s an example that shows the output of the dirs command on my system immediately after the command line terminal was launched: $ dirs Continue reading

Related

JOIN THE DISCUSSION

Comment moderation is enabled. Your comment may take some time to appear.