Written by Chris Gregg, with modifications by Nick Troccoli
Click here for a walkthrough video.
(Note: these commands are extra commands that you may find useful, but you may not have to use). As you work on projects with multiple directories, you may find that you want to move between directories but you don't want to keep typing the previous directory. There are two commands that allow you to keep track of previous directories and go back to them:
pushd
: pushes the current directory onto a stack and moves to that directory
popd
: pops the last directory off the stack and moves to that directory
For example:
$ pwd
/afs/.ir/users/c/g/cgregg/cs107/cs107/assign0
$ pushd /afs/.ir/class/cs107
/afs/.ir/class/cs107 ~/cs107/cs107/assign0
cgregg@myth5:/afs/.ir/class/cs107$ ls
cgi-bin private_data repos samples staff tools WWW
$ popd
~/cs107/cs107/assign0
$ pwd
/afs/.ir/users/c/g/cgregg/cs107/cs107/assign0
$
Another command to simply move you back to the previous directory you were in is cd -
, and this can come in handy if you just want to temporarily move to another directory and then come back.