NACSE - Northwest Alliance for Computational Science and Engineering
Next 5.D: Changing Directories Quickly  Up 5: Managing Files and Directories  Prev 5.B: List Command Options  Contents

Basic

§ 5.C:  Changing Directories Slowly and Carefully


Let's say we want to work in the directory development. We use the "change directory" command to get there:

> cd development

Notice that Unix does not give a response. For commands that do not request information, you get only a prompt asking "what next?". (Yet like many a domestic partner, Unix will not miss the opportunity to tell you if you did something wrong.) To check where you actually are and what's there, issue the "print working directory" and "list" commands:

> pwd
> ls -FC

You should get:

/userid/development

 data/  prog/ 

Now let's change to the data directory and list its contents:

> cd data
> ls -FC

Don't be offended if Unix did not say anything to you. Because there are no files in the data directory, Unix gave an empty response (think terse is nice).

In Unix, the current directory can be called by its proper name ~/development/data, or by the dot symbol "." all by itself. The next directory "up" in the directory tree can be called by its name ~/development, or by the "doubledot" symbols ".." all by itself. Because there are no files in the present directory (and nature abhors a vacuum), change directopry back to ~/development:

> cd ..

Now print the working director to see where you are:

> pwd

To look into a directory before you leap in, issue the "list" command with a directory name instead of a file name:

> ls data
> ls prog
> ls *

Here the "*" is a wildcard meaning any file in the working direcory; in which case the last command is the equivalent of the first two. Unix should respond with something like:


data:

prog:
area.f

We see that while the data directory is empty, the prog directory has the file area.f in it. To get ready for the next lesson, let's change to that directory:

> cd prog


Next 5.D: Changing Directories Quickly  Up 5: Managing Files and Directories  Prev 5.B: List Command Options  Contents

Comments and questions to Dr Elias N. Houstis enh@cs.purdue.edu.