• No results found

System Structure of UN

Appendix B Common Operations of UNIX System The appendix introduces features, terms and structure of the UNIX system and its

B.2 System Structure of UN

B.2.1 System Composition of UNIX

UNIX is a layered operating system, composed of Kernel, Shell and Application Program. The architecture of UNIX system is shown in Figure B-1.

Hardware Kern Kernel Shell Shell Application Program sh csh ksh Application Program

Figure B-1 UNIX architecture I. Hardware

The hardware that supports UNIX. It is the physical foundation of the whole operating system.

II. Kernel

As the core of the whole operating system, the Kernel controls the running of UNIX equipment and the computer resources, protects the user programs from being affected by the complicated hardware events. With the Kernel, the user program and system ourter-layer program will only in charge of the interactive operation with the Kernel, instead of taking care of the detailed information of the hardware.

III. Shell

As a special program in UNIX, Shell is the interface between the Kernel and the user. It is also an interpretive high-level language, serving as the command interpreter. A Shell is made up of some simple programs, running on top of the core program and dealing with all user inputs. Shells commonly in use nowadays are divided into three types: Bourne Shell, Korn Shell and C-Shell. Please refer to Table B-1 for details.

Table B-1 Introduction to UNIX Shells

Type Feature Abbr. Command Prompt

Bourne Shell The oldest and the most popular type that offered by all UNIX systems. It is the basis of

the three Shell programs. B Shell sh $

Type Feature Abbr. Command Prompt

C Shell

It is the most powerful one in the three Shell programs, which is closer to C programing language. However, the commands are difficult to remember. Therefore, it is more popular in colleges and universities.

C Shell csh %

Normally, Bourne Shell is the default shell of the system. To switch to another shell, simply input corresponding Shell command on command prompt. For example, to change from current Shell to K Shell, input the command "ksh".

IV. Application program

The programs in the outermost layer are the application programs developed by the user according to their actual needs. UNIX offers a great deal of tools and applications, such as vi editor, file searching and backup program, etc.

B.2.2 File System of UNIX

UNIX saves and handles files within its file system. Each system can set up and hold a large number of file systems. Generally speaking, a file system is similar to a drive in DOS. For example: a typical UNIX system may contain a root file system (/), a user file system (/user) and a master file system (/home). Those file systems can be saved in one or several hard disks. The file system can also be created in diskette and tape. UNIX treats the external devices (such as printer, diskette, etc) and directory as files. The UNIX file system developes on a tree structure. On top of the structure, it is the root of the tree – called the root directory, always indicated by "/". Tracking down from the root directory (/), we will find the subdirectories or lower level directories and files, until we reach the leaves of the tree -- the files in various subdirectories.

B.2.3 Directory Structure of UNIX

In UNIX file system, all files and file directories are contained in their parent directories. The parenet directory of the root directory is itself. In fact, a directory is just a list of information about all the related files and subdirectories.

Some files and directories will be generated for the user when the system installation is finished. The structures of the file directories are shown below:

z profile User environment parameter definition files. z bin Directory of executable files.

z etc Directory of configuration files, which stay unchanged during system

operation and don’t need to be restored after system upgrade.

z data Directory of data files, which will change during system operation and

shall be restored after system upgrade.

z script Directory of database installation script files.

B.2.4 UNIX System Files

The information of a UNIX file includes the owner of the file, the authority he has for the file, the date it is created, modified and last accessed, etc. Please refer to the following for details:

z Mode The protection mode and type of the file. z Link count The number of links.

z User ID The ID of the user owning the files.

z Group ID The ID of the group to which the file owner belongs. z Size The size of the file (in byte).

z Access time The time when the file was last accessed. z File name The name of the file.

The above information will be displayed when the command "ls" (list files) is executed. In a UNIX system, there is no special requirements on the file structure. The file can be ASCII file, binary file, or the combination of the two, and exist in the form of text file, script file or complied object code of a program.

B.2.5 Program of UNIX

Program, or command, can be used by the user to perform interactive operation with the Kernel, so as to customize certain working environment and accomplish specific functions. In a UNIX system, the prgram can be an executable shell file, such as a shell script file, an internal shell command and a source code or complied object code file, etc.

Shell is a command line interpreter, with which the user interacts with the Kernel and complies ASCII script file to be executed in shell.

The system programs (system commands) are ususally binary and complied from the source code in C programing language. They are normally saved in the directories of "/bin", "/usr/bin", "/usr/local/bin and /usr/ucb", etc. (varying with different UNIX systems), providing typical UNIX functions, such as sh, csh, date, who and more, etc.