10
Jun

Tips for Navigating Directories in Linux

Here are some basic Linux commands that will allow you to navigate easier within the terminal. These commands include dirs, pushd, popd, and cd.

cd
This is probably one of the most known commands since you really can’t get around a Linux terminal without it. There are some pretty neat tricks you can use to more quickly navigate directories. These include:

In order to talk about the next commands, you need to understand what a stack is. Imagine a spring-loaded plate holder like the ones you’d find at an all you can eat buffet (this is dirs). The employees fill this plate holder by pushing a plate onto the plate holder. Then another plate is pushed onto the top of that plate (this is pushd). This is repeated again and again and then soon, you have a full stack of plates. In order to get to any of the plates in the middle, you must pull the plate on top off, and then the next, and then the next until you get to the plate you want (this is popd). This can continue until the stack is empty. This example is known as a Last In First Out (LIFO) or First In Last Out (FILO) data structure and that’s exactly what we’re dealing with here.

Now that you have an understanding of what a stack is, let’s chat about the next three commands: dirs, pushd, popd.

dirs
This is the command you use to display the stack of currently remembered directories.

pushd
This command will push a given directory to the top of the stack of remembered directories.

popd
This command will pull the top directory off the stack of remembered directories.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 2 Comments So Far

Share your thoughts, leave a comment!