Unix - The UNIX Filing System

System Overview

The strength of the UNIX operating system is its hierarchical file store structure. A hierarchical file store structure can basically be viewed as an upside down "tree like" structure with the root, represented by a forward slash (/), at the top. Underneath the root are sub-directories each of which, in turn, is capable of further sub-directory sub-division.

Part of a typical UNIX system's file store structure might look like the following:


                                     /   (root)                                       |                                       |                                       |                                       | -----------------------------------------------------------------------     |          |          |           |           |         |      |    bin        usr        etc        disk     lost+found    tmp    dev                |                      |                |                 -----------------------                |                      |           |               tmp                     v           |                                       |         temp                                       |           |                                     abc2        abc2                                       |           -----------------------------------------------------                 |           |         |            |              Fortran      Docs       Bin         Test                 |           |         |            |              newprog    chapter2   testprog      demo



The top level (the root) tends not to have individual files stored in it but sub-directories containing various files, for example, bin usr etc disk lost+found tmp dev are all sub-directories.

 

Sub-Directories

A sub-directory is a special type of file: it is a file of files. You can "navigate" around the file store structure by using the "root" as the starting point. For example, you can refer to files stored in the sub-directory bin, or lost+found, by including the root symbol at the beginning of the directory's name: /bin or /lost+found. In referencing a file, or a sub-directory, further down the structure it is not uncommon to see its description starting at this root level. For example the file chapter2 above can be referenced via:

/disk/v/abc2/Docs/chapter2

This is interpreted as file chapter2 in sub-directory Docs; in a sub-directory abc2; in a sub-directory v; in a sub-directory disk from the root level.

NOTE: Directory names are punctuated by the "/" character.

Information on how to move around this directory structure can be found in the following sections.

Home Directory

When you log in to a UNIX system you are placed in a default working directory, or home directory, which is usually some way down the file store structure outlined in the previous section. For example, user abc2 has a home directory at:

/disk/v/abc2

For user abc2 this is a private area and any files stored there are only available to user abc2 (unless the file protections have been changed). You can create your own sub-directory structure from your home directory downwards but various privileges, and protections, will not allow you to create sub-directories wherever you want to!

 

File and Sub-Directory Names

UNIX file naming is very flexible! Files can be named using a wide variety of characters but it is recommended that you use the following sub-set of characters:

a - z A - Z 0 - 9 .

You should avoid using any of the following characters:

@ # ^ & ( ) ' ` " \ ; < > | * $ ? [ ]

NOTE: Standard UNIX only allows up to 14 characters to be used in a file, or directory, name. Also, remember UNIX is case-sensitive! A sub-directory called docs is distinguishable from a sub-directory called Docs or DOCS.

To the UNIX operating system a filename is just a sequence of characters, it does not have a concept of file extensions, as supported by various other operating systems, e.g. VAX/VMS or MS-DOS. If a filename contains a full-stop, e.g. chapter3.txt it is treated like any other character. However, there are situations where filenames must contain an extension, for example Fortran and C program source files must end with .f and .c respectively.

NOTE: There is no distinction between a filename and a sub-directory name, only careful phraseology will make it clear to the reader what is intended. For example, if, in a list of files, a name temp is seen it is not obvious whether this is a file or a sub-directory. Only by stating "the files stored in the sub-directory called temp" or "the contents of the file called temp" will the reader understand what is meant. Some users use the convention that sub-directory names begin with a capital letter e.g. Docs is a sub-directory, but docs is a filename.

 

 

Creating And Deleting A Sub-Directory

A file store structure is like a filing cabinet. You would not place all your papers in one drawer of a filing cabinet, as this would make them difficult to find, but you would partition drawers into logical division (letters, reports etc.). You should view your file storage space in a similar way and use sub-directories to partition your account into logical sub-divisions.

To create a sub-directory below the current working directory:

Type: mkdir directory_name

For example, to create a sub-directory called Test below the current working directory:

Type: mkdir Test

 

Source:http://www.le.ac.uk/oerresources/bdra/unix/page_26.htm