This is an example directory structure for the purposes of illustrating the use of pathnames. It does not correspond to the actual situation on turing.

           (root)
             |
             |
     ----------------
     |              |
    tmp            user
     |              |
          --------------------------
         |                          |
        kim                       sandy
         |                          |
    -----------               ---------------
    |          |             |              |
   Mail  file-for-sandy     todo          papers
    |                                       |             
 received                            ------------------
                                    |                  |
                                 syntax          chinese-tone.tex
                                    |
                             ---------------
                            |               |
                    swedish-word-order  russian-case
                            |
                     -------------
                    |             |
              swo-draft1.tex  swo-final.tex

Sandy is a user on this system. Her username is sandy. When she logs on, she is in her home directory, /user/sandy. When she types 'cd papers', she is in her papers directory, so 'ls' there would show the subdirectory 'syntax' and the file 'chinese-tone.tex'. Typing 'cd ..' (to go one level up) would bring her back to her home directory, and so would 'cd'. But you don't have to walk along step by step - you can make big leaps by specifying pathnames. For example, you can cd to 'papers/syntax/' directly, without going through 'papers'.

In fact, in many cases it's not even worth 'going' there at all, but can do whatever you wanted to do there by giving the pathname to the command directly, and avoid having to find your way back. For example, instead of doing

cd papers/syntax/swedish-word-order
ls
cd
you can say
ls papers/syntax/swedish-word-order
directly.
The above example uses a relative pathname. It assumes that 'papers' was an immediate subdirectory of the directory you started out from, i.e. in this example your home directory.
cd ~/papers/syntax/swedish-word-order
would be more general since this will work independently of which directory you're currently in. The tilda is an abbreviation of a complete pathname that mentions all the directories above your home directory, i.e. in this case
/user/sandy/papers/syntax/swedish-word-order
Pathnames like the above, which start with a / (for the root directory), are called absolute pathnames.
So, for example, if Kim has told Sandy to look at the file 'file-for-sandy' in this home directory, one way to do this is
more /user/kim/file-for-sandy
Of course, if Sandy is currently in her home directory,
more ../kim/file-for-sandy
would be just as fast. But the best option is
more ~kim/file-for-sandy
because it doesn't require knowledge of the actual complete pathname to Kim's home directory, which may not be as straightforward on a more complex system like turing.

If Sandy is using the tcsh, she can also use TAB completion to avoid having to type (and know!) full pathnames. For example, if she was in her home directory, typed 'cd p' and then hit the TAB key, the complete name of the 'papers' directory would be filled in automatically. This works whenever it's unique, i.e. it wouldn't work if she typed 'more s' TAB in her swedish-word-order directory. But it works until the point of divergence, i.e. the 'wo-' would be filled in, and then all she'd have to do is type 'f' and another TAB to look at the file swo-final.tex.

The wildcard *, which will match any string, has a related but different function. For 'cd' the effect could be almost the same - 'cd p*' typed in Sandy's home directory would have the same effect as 'cd p' TAB. But * won't work when there's more than one possibility, which makes it useful for other purposes, e.g. listing all files beginning with, ending in, or containing a certain string of letters.


Back up to the Main Computing Page