Quick directory switching

At work, I do a lot of directory traversal: going from one location to another within the whole (global) filesystem structure. So, to conveniently go back to a previous directory, I use pushd and popd, aside from the usual cd:

$ pwd
/home/iandexter
$ pushd /etc/sysconfig
$ pwd
/etc/sysconfig
$ popd
$ pwd
/home/iandexter

You can even echo $DIRSTACK to list the current directories in the stack, and push multiple directories.

3 Responses to “Quick directory switching”


  1. 1 Vikkicar

    If you’re familiar with FRIENDS, a line was said in one episode, that goes something like: “I know you’re talking but all I hear is BLAH BLAH BLAH…” Hee. Have a fine weekend. God Bless.

  2. 2 brainbox

    how about cd -

  3. 3 Ian Dexter

    Thanks, brainbox.

    But `cd -` works on a single level only. `pushd` and `popd` are bash only, though — not available in ksh. Then again, I’m almost always into bash.

Leave a Reply