It doesn't matter which of the standard shells are chosen, for all three have the same purpose: to provide a user interface to UNIX. To provide this interface, all three offer the same basic functions:
Command line interpretation
Program initiation
Input-output redirection
Pipeline connection
Substitution of filenames
Maintenance of variables
Environment control
Shell programming
Discussing the functions of the shell in detail is beyond the scope of this material.
THE FILE SYSTEM
One of UNIX's greatest strengths is the consistent way in which it treats files. Although some operating systems use different types of files each requiring unique handling, you can handle most UNIX files the same. For instance, the cat command, which displays a disk file on your terminal screen, can also send the file to the printer. That is, in UNIX, all devices are addressed as files. As far as UNIX is concerned, the printer and your terminal look the same and they look like any other UNIX file. UNIX also doesn't distinguish between files that you create and the standard files that come with the operating system—as far as UNIX is concerned, a file is a file is a file. This consistency makes it easy to work with files because you don't have to learn special commands for every new task. Often, the same command can be used for several purposes. This makes it easy to write UNIX programs because the user usually doesn't have to worry whether he’s communicating to a terminal, a printer, or an ordinary file on a disk drive. Besides, this ensures the effective control of the access to any device, which according to UNIX, is just another file.
3.3.1. THE TYPES OF UNIX FILES
There are four types of UNIX files namely,
Regular files
Directories
Special or Device files
FIFO files
REGULAR FILES
Regular files hold executable programs and data. Executable programs are the commands (such as cat) that you enter. Data is information that you store for later use. Such information can be virtually anything and there is no specific order of format enforced in the way the information is stored.
These files can be visualised as the leaves in the UNIX tree.
DIRECTORIES
Directories are files that contain other files and subdirectories, just as a filing cabinet's drawers hold related folders. Directories help you organise your information by keeping closely related files in the same place so you can find them later. For instance, the user might save all spreadsheets in a single directory instead of mixing them with other unrelated files.
The kernel alone can write the directory file. When a file is added to or deleted from this directory, the kernel makes an entry.
A directory file can be thought of as the branch of the UNIX tree.
SPECIAL OR DEVICE FILES
These files represent the physical devices. Files can also refer to computer hardware such as terminals and printers. These device files can also refer to tape and disk drives, CD-ROM players, modems, network interfaces, scanners, and any other piece of computer hardware. When a process writes to a special file, the data is sent to the physical device associated with it. Special files are not literally files, but are pointers that point to the device drivers located in the kernel. The protection applicable to files is also applicable to physical devices.
FIFO FILES
FIFO files are those that let unrelated files communicate with each other. These files are typically used in applications where the communication path is only in one way and where a number of processes have to communicate with a single process, often called the daemon process. Each message writes a message to the FIFO file and the UNIX system ensures that the other users do not overwrite a message written in the file.
4. THE UNIX FILE TREE
The designers of UNIX used directories to organise the UNIX file system into a structure that is shaped like an upside-down tree. Directories enable the user to keep related files in one place, where they can be seen only when wanted.
The figure that follows shows a part of the file tree for a typical UNIX system. In this drawing, which looks somewhat like an upside-down tree, names like home and jane are followed by a slash (/), which indicates that they are directories, or files of files. Note that ordinary files, such as cowboys and prufrock, are not followed by a slash. Such files are called leaves because they aren't connected to anything else. The connecting lines are the paths through the UNIX file tree. You can move around the tree by following the paths.
The file tree for a typical UNIX system
Unlike some operating systems, UNIX offers great flexibility in naming files and directories. The slash character cannot be used because it is the pathname separator and the name of the file tree's root directory. However, almost everything else is legal. Filenames can contain alphabetic (both upper- and lowercase), numeric, and punctuation characters, control characters, shell wild-card characters (such as *), and even spaces, tabs, and new lines.
No comments:
Post a Comment