Getting Started : Working with Directories

Unix filestore is divided into a tree of directories and subdirectories. At the very top level (or bottom level depending on how you look at it) is the root directory, represented by the / character. Below this are a number of system directories (such as /bin, /lib, /dev) together with the directories for user files. Users can subdivide their own directory into a number of subdirectories, so that they may group their files according to the different areas of their work.

 

                          /
                      /  /|\  \ 
                   /    / |  \   \ 
                /     /   |   \     \
            /      /      |     \      \
        /        /        |      \        \
    /          /          |        \          \
 /           /            |          \            \
usr         bin          lib         u1           u2  
                                      |
                                      |
                                      |
                                     Fred
                                     /|\
                                 /    |   \
                             /        |       \
                         /            |           \ 
                        bin          data         plants
                                                     |
                                                     |
                                                     |
                                                  results

Figure 1 Example Directory Tree

So, the main login directory (the home directory) for the user fred who has been allocated to the u1 directory would be /u1/fred. The full filename for fred's file results1 in the subdirectory plants would be /u1/fred/plants/results1. Assuming the user fred was working in the default, home directory, then only plants/results1 need be used to refer to the file.

The mkdir and rmdir commands should be used to create and delete directories respectively. See the relevant man entries for these commands.

 

Moving Around the File Structure

The pwd command will display the setting of the current working directory. This is the directory where files will be read from or written to if no other directory path information is given on filenames.

To change the current working directory, use the cd command. This takes one argument, the directory path where you wish to work. The cd command on its own will move back to your home directory, while cd .. will move back up one level in the directory tree.

A tilde (~) can be used as a shorthand for a home directory. For example, if /fred is the home directory, cd ~/progs will move to /fred/progs. A tilde followed immediately by a username will be expanded to that user's home directory.