The Working Directory and pwd
Written by Chris Gregg, with modifications by Nick Troccoli
Click here for a walkthrough video.
Whenever you are running programs, you will have a "working directory" that represents where your program starts looking for files. This is often the directory where you launch the application from, which is not necessarily the directory where the program itself resides. To determine the directory where you are currently located, use the pwd
command, as follows:
$ pwd
/afs/.ir/users/c/g/cgregg
If you change to another directory, you will have a new working directory:
$ pwd
/afs/.ir/users/c/g/cgregg
$ cd 107
$ pwd
/afs/.ir/users/c/g/cgregg/107
If you run a program and it cannot find your files, the first thing to check is the working directory.