next up previous contents
Next: Finding files (find, locate) Up: Files and the File Previous: Listing the files in   Contents

Setting and showing your current directory (cd, pwd)

If you would like to change your working directory use the command cd. The basic format is:

cd directory

If you type just cd, with no directory name, Unix will put you back in your home directory.

If you ever become confused and disoriented about which directory you are in, use the command pwd. This command prints the pathname of your working directory. E.g.:

malama% pwd
/home/bbaggins/demons

The logical question to ask now is: ``What are those slashes and what do the names u, bbaggins and demons represent?" Your home directory is part of the file system hierarchy. It is found in the directory /u with other users' home directories. In this fictitious situation the home directory is ``bbaggins''; ``demons'' is the name of a subdirectory. Everything in the filesystem, regardless of which physical disk the files are on, starts at the ``/'' level; ``/'' is actually a directory itself, and everything else is a subdirectory underneath it. The other slashes just represent divisions between different levels.

There are three special symbols for particular directories: ``.'' is always the current directory, ``..'' is always the parent of your current directory, and ~username is the default login directory of the account with that username. If you are referring to your own home directory, ~ by itself is enough. You can use these symbols with any file-oriented command. They can be used to shorten the path you give to cd to get to a particular directory. For example:

malama% ls -aF truein

      ./       .cshrc      demons/      test/
      ../      .login      params       testprog*
truein malama% cd demons
malama% cd ../test

In some cases, your home directory on one system may actually be on a disk connected to a different system (see the section in Part II on Disk Space Setup for an explanation of why this may be the case). If so, when you use pwd, you will see the name of another system in front of the disk name, e.g. /home/lehua/u. You need not treat your files any differently. If you refer to your home directory as ~, the system will always be able to find it regardless of exactly where it is.


next up previous contents
Next: Finding files (find, locate) Up: Files and the File Previous: Listing the files in   Contents
h.stilmack@jach.hawaii.edu