We can push our directories into a directory stack, and pop when we needed. Sometimes we need to access many long path of directories, we can save it by pushing it to directory stack.
If you do not know what is stack, please help yourself to read this. Stack is a temporary data storage based on the principle of Last In First Out (LIFO). The last item you push to stack, will be the first item you pop out.
To play around with directory stack, we need
Let say you are in the directory /var/games now, you can push this directory into the stack
Now you go to another directory, let say “dump” at your home directory. Again you do this.
Go to more directory and do the command line show above. They to see what you have at the directory stack, do this
For example my current dirs result shows:
~ /root /var/games ~/dump
The ~ indicate that I am currently at my home directory and I have additional dir store in stack.
Let me do this
After doing this, I will be at /root and dirs to see my stack again.
/root /var/games ~/dump
My current directory is at /root, which I have losing an item in the stack.
I usually do this for important directory. I usually list all of them in new line for each.
Let say the current stack of mine looks like:
~ /root ~/mp3/Akiko /var/games ~/dump
I am currently at my home directory, let say I wanna travel to 2nd dir, which is ~/mp3Akiko, without poping out from stack, I can do this trick.
cd `dirs +2`