Previous Table of Contents Next


FILE SYSTEM

UNIX uses a hierarchical structure to store and maintain files. This structure is referred to as a tree structure from its resemblance of an upside down tree. The UNIX file system starts with one master directory called "root." Since the tree is upside down, the "root" directory is at the top. The root directory, symbolized by a single "/", has multiple directories under it.

This tree structure allows maximum flexibility for storing information to resemble its logical or real life structure. Multiple users may be grouped by corporate department. As an individual user you may group your data by project or subject. The options are almost limitless and the result is a very flexible and productive environment.

The file system is used by the UNIX operating system to store and control system and user files, directories, and special files. It allows a logical and simple method to maintain large quantities of files with little effort.

The file system operations are performed internally by the UNIX System but there are many utilities that can be used to manage and manipulate the information stored within a file system.

The UNIX operating system has three concepts of files within the file system, the directory, ordinary file, and special file. When using the term file we are usually referring to an ordinary file.

Characteristics

The following list describes the characteristics of the UNIX file system.

Hierarchical structure - Allows grouping of related information and efficient manipulation of these groups.

Dynamic file growth - Files grow as needed, no advanced decisions have to be made about file sizes. Disk space is not wasted since only the amount required to store the current contents of the file is used.

Structureless files - There is no internal structure imposed on the contents of a file. Any structure desired by the user can be used.

Security - Unauthorized users can be restricted from accessing a file.

Device independence - Input and Output from a device is processed as if it were in a file. Therefore, programs that process data in a file can also process data to and from a device.

Limitations

File sizes cannot exceed 4 gigabytes (2^32). As files increase over 10,000 bytes in size, the access time required to retrieve the data increases. This is caused by indirection to locate the block of data.

As the number of entries in a directory increases, the access time to view or manipulate the directory increases. In-core (file system information stored in RAM) file system information may be lost if the system crashes.

DIRECTORIES

A directory is a storage area where any combination of files and subdirectories can be managed. You can think of a directory as a filing cabinet drawer, used to store related file folders. Each directory has a name and each file within the directory has a filename.

Directories are used to store multiple files according to the needs of you, the user. Some people organize their directories according to subjects. Others may organize them based on projects or time schedules. The point is to utilize the freedom provided by the file system to organize them as you see necessary.

The UNIX System is distributed with an established set of directories. There are many system directories and possibly locally created system directories. Check the vendor's Release Notes, Install Procedures, or System Administrator's Guide for a full list or ask your system administrator.

The / (root) and /usr file system must be mounted for the system to be fully functional. The root file system contains the essential files and utilities. The /usr file system contains more general files and utilities. On smaller systems the /usr directory is not a file system but is part of the / file system.

Limitations

As with a physical file cabinet drawer you can only put a specific number of file folders in the drawer. A directory has a physical limit of files in the thousands.


NOTE:  
It is advisable to limit the number of files in a directory to under 100. Some systems can actually handle up to 500 files in one directory but 100 is still a good limit. There are two major reasons for this limit. The first is performance. If more than 100 files exist in a directory, the UNIX System encounters high overhead to perform various file system functions in that directory. The second reason is user sanity, referred to by some people as "organization." If you try to keep too many files in one directory, you begin to lose track of where you stored your data.



The directory name can be a maximum of 256 characters, consisting of any character, including a white space. Some characters may have to be escaped or quoted to perform this trickery, but it is possible, though not often desired. Some systems allow up to 1024 characters in the filename.

ORDINARY FILES

Ordinary files are used to store data. A file is like a folder in a filing cabinet; many different types of information may be stored in the file. Files may be ASCII text, compiled programs, or free formatted application controlled data. Files may grow as needed without intervention from the user. This makes it easy for the user and saves space on the physical storage device.

Internal Structure

An ordinary file has no internal structure defined. The data may be stored in any format desired. The UNIX System views files as a stream of bytes, it reads and writes them byte-by-byte or block-by-block, not interpreting the data.

UNIX identifies files by a unique number called an inode number. Inode numbers are maintained in a directory file along with the related filename. If you refer to a file by its filename, the system uses the related inode number to retrieve the physical data.


Previous Table of Contents Next