my parents, Sri (Late) V. Muthanna and Smt. M. Gowramma
PREFACE
Unix is one of the most powerful and widely used operating systems. It was conceived at AT&T's Bell Laboratories during early 1970s. Among many who fostered this operating system, particularly at the early stages, the contribution of the University of California at Berkeley is notable. Since then, it has grown in strength day by day. The sheer existence of this operating system over the past three decades itself speaks for its strength. It offers word-processing capability, networking facility, information retrieval and processing, and much more. Although powerful, it was not popular among users initially because it was developed for researchers by researchers, had trade restrictions, and also lacked a user-friendly device.
The addition of a GUI in the form of X-Window System and the availability of one of its freeof-cost versions called Linux during the 1990s, along with the falling prices of hardware, has resulted in expanding its user base.
. It also deals with the commands that are used to navigate a Unix file system as well as some file handling commands.
Unix files have many attributes. These attributes are discussed in . Also included in this chapter is a discussion on how attributes of a file can be known and manipulated.
Piping and the concept of standard I/O and redirection are the topics that are chiefly discussed in . This chapter also gives the meaning of a filter and deals with two of the more useful filtersthe sort and the tr commands.
Unix has different types of editors such as ed, ex, vi, vim and emacs ..
The concept of process, the mechanism of the creation of a process, and certain essential commands that deal with processes have been discussed in . Also included in this chapter is a discussion on signals and their usage in handling processes.
discusses shell programming. The shell variables, positional parameters, branching and loop control structures along with essential commands that aid in writing and successful execution of shell scripts are also discussed in detail.
is a discussion on awk , a C-style programming language primarily used for information retrieval and report generation tasks. Some simple and useful awk scripts are also included in this chapter.
deals with some of the basic communication tools that are available in Unix.
explains the essentials of Perl, one of the excellent languages which has the combined powers of many other powerful Unix tools such as the shell, the grep , and awk .
gives a brief overview of system administration, specifically at an introductory level, and also talks about the way in which a Unix file system stores and maintains all of its relevant information on a physical device like a hard disk.
The contents of this book have been selected such that it could be taught in a semester for four credits as a first course at the degree level. All the discussions in this book chiefly refer to the Bourne shell. However, certain features like background processes, repeating commands using the history facility and aliases that are not found in the Bourne shell have also been discussed. Brief references to Linux have been made at all the possible places. All the scripts presented in this book have been tested successfully.
This book introduces the basic concepts of a Unix operating system in general and also gives a sufficient knowledge on writing scripts with different Unix languages such as awk, perl and shell . This book assumes prior working knowledge in the C programming language.
M. G. VENKATESHMURTHY
1
INTRODUCTION TO UNIX
Chapter Objectives
- Evolution and features of Unix
- Unix system structure
- The role of a shell as a command processor
- Using Unix
- Types of Unix commands and their general features
- Some basic general utility commands
- Getting on-line help
- Command substitution
- Giving multiple commands
Unix has a very long history and a large number of commands. This chapter begins with a brief discussion of the history of Unix development. The salient features of a Unix system and its various components is discussed briefly. The meaning of a command, broader classification of Unix commands, and the action of some of the useful commands are also discussed here. Details about a particular command can be obtained by going through the manual pages by using the man command, if necessary.
1.1 BRIEF HISTORY
Unix has a longer history than any other popular operating system. Though many schools have contributed to its development, the initial contributions by The Bell Laboratory of AT&T and the University of California, Berkley (UCB) are notable.
Bell Laboratorys contribution In 1965, Massachusetts Institute of Technology (MIT), General Electric, and The Bell Laboratories of AT&T worked on a joint venture project called Multics (Multiplexed Information & Computing System), which intended to develop a multi-user operating system. As the progress was not satisfactory, AT&T withdrew itself from the Multics project in early 1969.
On the basis of the ideas acquired while working on Multics, Ken Thompson, a researcher started working on a different project. He came across an abandoned PDP-7 machine on which he and Dennis Ritchie developed an operating system (OS), called UNICS (Uniplexed Information and Computing System) during the latter part of 1969. UNICS was developed completely in the assembly language of PDP-7 and so it was not portable. To achieve portability, Thompson considered implementing the system in a higher level language. He worked on the development of a higher level language called B, an off shoot of an earlier language called BCPL. As the B language did not yield the expected results, Ritchie developed a higher level language called C in 1973. At the same time many researchers in AT&T showed interest in the Unix project (around 1970 UNICS became Unix). During those days many text-processing utilities along with a text editor called the ed editor and a simple command interpreter called the shell were developed. The ed editor was a line editor and the then developed shell became the Bourne shell ( sh ), the grandfather of almost all the currently available shells.
The results of the research and the developments made at the Bell laboratory were first published in the form of the Unix Programmers Manual in the late 1971. Since then, there have been a total of 10 editions of this manual. Each of these manuals correspond to a version of the Unix released by AT&T. The third edition published in early 1973 included the details of a C compiler. Ritchie completely rewrote the entire Unix system during the same year using C. Actually around 95% of this Unix system was written in C and the remaining was written in the assembly language. The platform used was a PDP-11 machine. The details of the Unix implementation in C was made public through a paper published in 1974. This paper was quite popular and its authors, Thompson and Ritchie were later awarded with the prestigious ACM Turing award. This paper attracted attention of a large number of people from inside as well as outside of the AT&T laboratory.