user-avatar
Today is Friday
April 19, 2024

December 9, 2009

pushd and popd commands

by viggy — Categories: linux, tech — Tags: , , , Leave a comment

Suppose you are presently working some directory and for some reason you need to cd into some other directory for some trivial but urgent work. So how do you remember which directory you were in. This is where pushd and popd commands are used.
Pushd command adds a directory to the top of the directory stack, or rotates the stack, making the new top of the stack the current working directory. With no arguments, exchanges the top two directories and returns 0, unless the directory stack is empty.
sumit@sumit-Desktop:/var/www/cgi-bin$ pushd /usr/share/apps
/usr/share/apps /var/www/cgi-bin
sumit@sumit-Desktop:/usr/share/apps$

and popd command removes entries from the directory stack. With no arguments, removes the top directory from the stack, and performs a cd to the new top directory.
sumit@sumit-Desktop:/usr/share/apps$ popd
/var/www/cgi-bin
sumit@sumit-Desktop:/var/www/cgi-bin$

I hope it is useful. Definitely very useful for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>