Chapter 1

Understanding and usage of Operating System
1.0 Introduction
Without software, a computer is basically a useless lump of metal. With its software, a computer can store, process and retrieve information and engage in many other valuable Activities to earn its keep. Computer software can be divided roughly into two kinds: System program, which manage the operation of the computer itself, and application programs, which perform the actual work the user wants. The most fundamental system program is Operating System, which controls all the computer resources and provides the base upon which the application program can be written. A modern computer system consists of one or more processors, some main memory, disk, printers, network interfaces and oth er input/output devices. It is all in all, a complex system. Writing p rograms correctly, is an extremely difficult job. If every programmer had to be concerned with how disk drives wo rk, and with all things that could go wrong when reading a disk, it is unlikely that many programs could be written at all. Some way had to be found to shield programmers from the complex ity of the hardware. The way that has evolved gradually is to put a layer of software on top of bare hardware to manage all parts of the system. This layer of software is the Operating System.

The situation is shown in the following figure. At the bottom hardware, which composes two or more layers. Lowest layer contains physical devices, consisting of Integrated circuits chips, wires, power supplies, CRT and similar physical devices.

Next comes primitive software that directly controls these devices. This software is called Microprogra m usually located in Read Only Memory. The set o f instructions that the microprogram interprets defines the Machine Language. In this layer Input / Output devices are controlled by loading values into special device registers. Next layer is operating system. The major function of the operating system is to hide all this complexity and give the programmer a more con venient set of instructions to work with. On top of the operating system is the rest of the system software. Here we find, Command Interpreter (Shell), Window system, Compilers, Editors and similar application independent programs. Finally above the system progr ams come the application programs. These programs are purchased or written by the users to solve their particular problems for Ex: Word processing, Spreadsheets, Engineering Calculations, Games etc.

1.1 What is an Operating System
An Operating system is a program that controls the execution of application programs and acts as an interface between the user of a computer and the computer hardware. An Operating system mainly performs three functions • Convenience : It makes computer more convenient to use • Efficiency : It allows the computer system resources to be used in an efficient manner • Ability to solve: It should be constru cted in such a way as to permit the effective development, testing and introduction of new system functions without at the same time interfacing with service. The Operating system typically provides services in the following areas : • Program Creation: Operating system services editors and debuggers, to assist programmer in creating programs. These services are in the form of utility programs that are accessible through the Operating System. • Program Execution: Program execution needs instructions and data to be loaded in to main menu, Input / Output devices and files to be initialized and other resources to be prepared. The operating system handles all these tasks for the user. • Access to Input / Output devices: Each Input / Output device requires its own peculiar set of instructions of control signals for operation. Operating system takes care of details so, the programmes can think in terms of simple read and writes. • Controlled access to files: Operating system provides protection mechanisms to controlled access to files • System Access: Operating System controls access to the system as a whole and to specific system resources. • Error detection and response: Variety of errors can o ccur which a computer system is running, i.e., internal and external hardware errors, such as memory error, device failure error, various software errors, inability of Operating

System to grant request of an application errors and so on. In each case, Operating System must make the response that clears the error condition. The response may range from ending the program that caused the error, to retrying the operation to simply reporting the error to the application. • Accounting : A good Operating System collects usage statistics for various resources and monitors performance parameters such as response time, which can be used for billing purposes on a multi-user system. Operating System as Resource Manager: A computer is a set of resources, the operating system is responsible for managing these resources. Operating System controls the movement, storage and processing of data. Operating system functions in the same way as ordinary computer software. i.e., it is a program executed by the processor. This frequently relinquishes control and must depend on processor to allow it to regain control. Operating System is nothing more than the computer program. This provides instructions to processor like other programs do. Main diff erence between Operating System and other programs is, Operating System directs the processor in the use of the other system resources and in the timing of its execution of other programs.

1.3 History of Operating System:
• First three digital computers were designed by English Mathematician Charles Babbage in 1792-1871. It was purely mechanical design. • After Babbage’s efforts little progress was made in constructing digital computers. In (1945-1955) First Generation Computers with Vacuum tubes and plug boards were evolved. In these d ays a single group of people designed, built, programmed, operated and maintained each machine. Programming was done in Machine Language. • Second Generation (1955-65) Transistors and B atch System. Here for the first time between the programmers and maintenance persons, Transistors were introduced. To run a job, a programmer would first write the program on paper, then punch it on cards, bring the card deck down to Input / Output room batch system was to collect a tray full of jobs in the Input / Output room and then read them onto a magnetic tape just to reduce the wasted time. • Third Generation (1965-1980) Integrated Chips and Multiprogramming In this generation, Integrated circuits were used, providing a major price/performance advantage over second generation machines, which were built up from individual transistors. Concept of Multiprogramming was introduced. When the current job was to wait for a tape or other Input / Output operation to complete the Central Processing Unit simply sat idle until the Input / Output finished. As the Central Processing Unit time is very precious this wasted time is not significant. The solution was to partition menu into several pieces, with a different job in each partition as shown in the figure Job3 Job2 Job1 Operating System below:

.

another job could be using the Central Processing Unit.Job3 Job2 Job1 Operatin g System While one job was waiting for Input/Output to complete. in which each user has an On-line terminal. Central Processing Menu could be kept busy nearly 100% of time. The following figure shows Multiprogramming with two programs: 5 . Thus if there are n users actively requesting service at one time. Another major feature in Third Generation System was the concept of time sharing. if enough jobs could be held in main menu at once. the processor time is Shared among multiple users in time sharing systems. each user will see on average only 1/n of effective computer speed. As multiprogramming allows the processor to handle multiply and batch jobs at a time. The basic idea for time sharin g system is to have multiple users Simultaneously using the system with the Operating System inter leaving the execution of each user program in a sho rt burst of computation. Therefore. This concept is called as Multiprogramming.

Five major achievements in the development of Operating System are • Process • Memory Management • Scheduling and Resource Management • Information protection and security • System Structure 6 .Program A Run Wait Run Wait Program B Wait Run Wait Run Combined Run A Run B Wait Run A Run B Wait • Fourth Generation (1980-present): Personal Computers: With the development of LSI (Large Scale Integration) circuits. universities and government installations are usually called Work Stations (Large Personal Computers). Usually they are connected together by hardware. chips containing thousands of transistors in a square centimeter of silicon. An interesting development that began during middle 1980’s is the growth of hardware of Personal C omputers running hard ware Operating System and distributed Operating System. In hardware Operating System. Personal Computers are not that different from mini computers. The most powerful Personal Computers used by business. the users are aware of the existence of multiple computers and can log in to remote machines and copy files from one machine to another. the age of personal computers dawned. 1.5 Operating System Concepts: Operating Systems are among the most complex pieces of software.

it is required to monitor and control the various programs executing on the processor in a systematic way. Thus process is realized as a data structure. which is maintained by Operating System. Base and limit register defines the region in memory occupied by th e process. The design of system software to co-ordinate the various activities turned out to be difficult. A process can either be executing or awaiting execution. Multiprogramming batch processing. If two processes A and B exist in a portion of the main memory. time sharing and real time transaction. Program counter points to the next instruction in that process to be ex ecuted. each of which involved numerous steps to be performed in sequ ence. An Operating System. So many errors were detected which were difficult to diagnose because they needed to be distinguished from application software errors and hardware errors. Process is a program that is in execution. With many jobs in progress at any one time. efficient and orderly control of storage allocation. • An executable program • The associated data needed by the program • Execution context of program Execution context includes the information that the Operating System needs to manage the process and that the processor needs to properly ex ecute the p rocess.• Processes : It is somewhat more general term than job. • Memory Management : Users need a computing environment that supports the flexible use of data. To tackle these problems. The concept of process provides the foundation process consists of the following three components. Three major lines of computer system development created problems in timing and synchronization that contributed to the development of the concept of the process. it b ecame impossible to analyze all the possible combination of sequences of events. The entire state of process is contained in its context. each process is recorded in process list. Process index register contain the index in to the process list of the process currently controlling the processor. to satisfy these requirements has five principal storage management responsibilities as follows: 7 .

The security 8 . Other portions of program and data are kept in blocks in disk itself and will be brought to main memor y whenever its execution is required. • Long term storage : Man y users and application require means for storing information for extended periods.. • Inf ormation protection and security : Operating System must support a variety of protection and security mechanism to computer system and the information stored in them. Users and applications are given security clear ances of a certain level. security classes are defined to enforce a particular dissemination policy. Virtual Memory is a facility that allows program to address memory from a logical point of view without regard to the amount of main memory physically available. destro y and alter the size of modules dynamically. Operating Systems meet these requirements with the concept of Virtual Memo ry and file system facilities. whereas data and other resources (e. Operating System can achieve efficiency by assigning memory to jobs only as needed.g. I/O devices) are given secu rity classifications. • Support of Modular Programming : Programmers should be able to define program modules and to create. processes are completely isolated from each other and each process has exclusive control over resources statically or dynamically assigned to it. • No sharing originals of program or data files • Controlled information dissemination : In some systems.• Process Isolation : Operating System must prevent independent process from interfacing with data and memory of each other. • Automatic Allocation and Management : Programs should be dynamically allocated memory across the memory is required. when a program is executing only a portion of program and data may actually be maintained in main memory. That is. Some overall protection policies are: • No sharing : In this case. • Protection and Access Control : Sharing of memory at any level of memory hierarch y. Operating System must allow portions of memory to be accessible in various ways b y various users.

For example. This is especially so for jobs of the same class. • Efficiency : Within the constraints of fairness and efficiency. minimize response time. which are charged the same rate. and data. and regulating process access to various resources and objects within the system • Information flow control : Regulates the flow of data within the system and its deliver y to users • Scheduling and Resource Management : A key task of the Operating system is manage the various resources available to it (main memory space. processors) and to schedule their use by the various active processes. we would like all processes that are competing for the use of a particular resource to be given approximately equal and fair access to that resource. the operating system should attempt to maximize throughput. It is up to the 9 . The short-term queue consists of processes that are in main memory (or at least an essential minimum portion is in main memory) and are ready to run. accommodate as many users as possible The operating system maintains a number of queues. • Differential responsiven ess : On the other hand. the operating system may need to discriminate between different classes of jobs with different service requirements. and in the case of time sharing. The operating system should attempt to make allocation and scheduling decisions to meet the total set of requirements. each of which is simply a list of processes waiting for so me resource. The operating system should also view these decisions dyn amically. I/O devices. jobs of similar demands. that is. the operating system may wish to schedule that process for execution as soon as possible to free up the device for later demands from other processes.policy enforces restrictions concerning which users have access to which classifications • Access Control : Is concerned with regulating user access to the total system. sub systems. An y resource allocation and scheduling policy must consider the following three factors : • Fairness : Typically. Any one o f these p rocesses could use the processor next. if a process is waiting for the use of an I/O device.

And finally. The operating system receiv es control. With clean. In this case. There is an I/O queue for each I/O device.short-term scheduler. Again. 10 . operating systems are chronically late in being delivered. Priority levels may also be used. the operating system must be sure that it does not over-commit memory or processing time by admitting too many processes to the system. minimal interfaces between modules. In any case. The operating system adds jobs to the system by transferring a process from the long-term queue to the short-term queue. once the interrupt or service call is handled. The modules must have well-defined interfaces to each other. The lon g-term queue is a list of new jobs waiting to use the system. such as an I/O device handler. the operating system must determine which pr ocess to assign to an available I/O device. and the interfaces must be as simple as possible. Thus. At that time. or dispatcher. More than one process may request the use of the same I/O device. the systems have latent bugs that show up in the field and must be fixed and reworked. System Structure As more and more features have been added to operating systems and as the underlying hardware has become more complex and versatile. This helps to organize the software development pro cess and limits the task of diagnosing and fixing errors. Certain points seem obvious. performance is often not what was expected. A common strategy is to give each process in the queue some time in turn. the size and complexity of operating systems has grown. Second. this is referred to as a round-robin technique. All p rocesses waiting to use each device are lined up in the device queues. a portion of main memory must be allocated to the incoming process. A pro cess may specifically invoke some operating system service. to pick one. To manage the complexity o f operating systems and to overcome these problems. one module can be changed with minimal impact on other modules. the short-term scheduler is invoked to pick a process for execution. of the p rocessor at the interrupt handler if an interrupt o ccurs. It also makes the task of system evolution easier. First. This goes for new operating systems and for upgrades of older systems. The software must be modular. Again. The size of a full-featured operating system and the difficulty of the task it addresses have led to three unfortunate but all too common problems. this eases the programming task. a service-call handler is the entry point in to the operating system. by means of a service call. much attention has been given over the years to the software structure of the operating system.

Process is a program that is in ______________ 2. Operating System allows _______________________ to be used in efficient manner 11 .EXERCISE True or False 1. First Generation Computers were purely mechanical 3. Operating System is a System Software 2. The most fundamental system program is ________________ 4. Secondary Memory is called Virtual Memory Fill in the blanks 1.Chapter 1 . Major features of Third Generation System was the concept of ____________ 3.

The Disk Operating System shell is actually an interface between you and the command interpreter that provides an easy way to enter commands. The part of Disk Operating System that controls the hardware such as the video screen. the read only memory of the computer or the firmware. If you are working at the command prompt. the Start Programs screen appears. A second part of Disk Operating System that interprets your commands and causes the kernel to do what you want is called the Command Interpreter. the computer with instructions from BIOS. Drive A: of a microcomputer is the primary drive. Nevertheless. A PC has floppy drives only and th e first floppy drive is conventionally called drive A: whereas the second floppy driv e is designated as drive B: Booting is synonymous with starting a computer. mouse. the last line on the screen looks like this : C:\> This line may be the only one on the screen. Each time Disk Operating System is started. When you switch on the computer first thing in the morning. the command prompt is automatically displayed on your screen. It reads the disk in drive A: for 12 . I will use the term command prompt to refer to it since the prompt is its visible part that you use to communicate with the kernel. Since the Disk Operating System shell is easier to use than the command prompt. Disk Drives and Directories : A disk drive is a device which runs the disk (floppy or hard) and in the process either storing data or reading from it. checks the memory and peripheral routines. However. More precisely. which a computer looks for first o f all on switching on. keyboard. First let’s see which interface is waiting for your command.Chapter 2 INTRODUCTION TO DOS Disk Operating System manages your computer’s resources. you can set up your system to have the Disk Operating System shell automatically displayed instead. disks and printer is the Kernel. When the Disk Operating System shell is first set up and is waiting for your command. the command interpreter converts commands you enter at the command prompt to their required form and gives them to the kernel. which are programs fused in to ROM.

To change the default drive. skipping drive B: as per specific B IOS instructions. After you enter the command you press the {Return} key to record your command. A> tells you the current default drive. The line at which you enter your command is called the Ms-DOS Command Line.any boot record or system files. Until you press {Return} you can correct any typo gr aphical mistakes that you may hav e made while entering your command. Firstly. When you boot from A: drive DOS diskette must be in driv e A: snu gly inserted with drive door properly closed otherwise disk in drive A: will not be read. FORMAT allows you to specify a volume label. the FORMAT command converts an off-the-shelf disk to a disk that DOS can use. or C. If drive A: does not have these it goes to the drive C:.. Once th e DOS is loaded it is said that the DOS has been booted and the computer is ready to accept your order. DOS will search this drive for all files. The following prompt stares at you and awaits your orders: A>_ or C>_ will be displayed along with a flashing cursor depending upon whether the system has been booted from A: or C: drive. simply enter the drive desired as follows: drive: (for example B: or C: or A: and Press {Return} The DOS FORMAT command performs several functions.txt 13 . Give the following command to format diskette in drive B: A>format B:_ <Return> DOS files names are of the form Filename. Lastly. MS-DOS is a command-driven operating system. This means that there are a set of commands which you give to the operating system for the tasks you wish it to perform. These commands are entered in front of the System Prompt (A. to read the same. Unless overridden by the command. FORMAT places a list of damaged disk locations on the disk so that DOS will not try to use those locations to store data. FORMAT can make a disk bootable by DOS if you use the /S qualifier in the FORMAT command. When you boot from C: drive DOS must be previously installed in the hard disk so that the system files are duly loaded in to RAM. or B.) at the place you see the blinking “hyphen” which is the cursor. Secondly. On finding these the computer starts the process of loading DOS in to the RAM of the computer. Thirdly.

A> DIR {Return} DIR/p <Return> It displays the directory page wise.”. which makes the period an illegal character in DOS file names. On pressing any key the next portion of 23 lines will be displayed. The DOS directo ry command DIR lists the files on a disk. DOS reserves several names for the devices that are attached to your computer. must contain from one to three characters. 14 . By directory is meant the list of files and/or sub-directories that are present in a floppy disk or hard disk. The following are valid DOS file names: CHAPTER. CON. P represents pause so a screenful with 80 columns by 23 lines is displayed.DAT MATH. Only the three-char acter extension in DOS file names is optional.The file name must contain one to eight characters. The file name and extension are separated by a period. The extension is optional and. A period separates the file name from the extension. NEW. the date and the time of creation of the file..DAT is illegal because CON is a DOS device name.DAT is illegal because the file name portion of a DOS file name can not exceed eight characters. The extension on DOS file names is optional and if present. If the entries are more th an 223 lines the computer will prompt you “Strike a key when ready ……….DATA is illegal because of extension DATA is more than three characters in length.HW SCIENCE.Jan Personal Off_Jan.DAT is illegal because of the two periods. The display will show the primar y file name. At the end of the director y listing it will also show the total number of files and the n umber of free bytes of space available. the space used.10 DATA….$$ Letter.RPT DO_TODAY EXPENSES. must contain from one to three characters DOSFILENAME. The followin g are illegal DOS file names on account of these being reserved desired names: AUX CON LPT3 CLOCKS LPT1 LPT2 NUL COM1 COM2 The .234 is illegal because it lacks a file name. the extension. if present.TXT NOTES.

C:\> DIR FILENAME. BASIC DOS COMMANDS 1. * represents all characters. C:\>DIR C: <Return> is the command to see the d irectory of C:. C:\>DIR A: <Return> is the command from drive C to see directory of disk in drive A.EXE will be displayed. A:\>COPY COMMAND.EXE will be displayed. C:\>DIR *. A>DIR S*. * is also called a wild card character.EXE You will see all the files having primary name which starts with S and with extension .COM from drive A to B. This way you can get more file names on the screen at one time. The command is used to quickly browse through the list of all files present in a disk or directory.* Represents all the characters of the primary file name if it is written prior to the extension dot.* <Return> is the command to display the files having the same primary name (say FILENAME) but different extension.EXE You will see all the files having extension . C>DIR ???A.?B? The above command will search for all files that have a primary name of 4 characters with the fourth character as A and an extension of 3 characters with the middle character as B. if any.SYS 15 .? is a character which represents an y single character in a file name. ? is called a wild card ch aracter.Allows color to be added to the video display Format DEVICE=C:\DOS\ANSI. ANSI -. <R eturn> is the command to see the names of just the sub directories present in the root directory of the hard disk C. The difference between ? and * is only that where as ? represents single character. C:\>DIR *. If entered after the extension dot it represents all the characters given to the extension. A>DIR *.COM B: {Return} is the command to make a cop y of the file COMMAND. It will not <Dir> entry no r it will give the space used and the d ate and time of creation of individual files.DIR/W <Return> The above displays the files and directory entries across the screen with W standing for “wide view”. This technique is used to search those files whose full names are not known or are temporarily forgotten. However. the display will consist of only p rimar y name and extension. Thus the above command will show all the files located in C drive.

BACKUP – Makes a flopp y-disk backup of your hard disk Format BACKUP C:\*. CONFIG – Configures DOS on startup Format (Executes automatically on startup) 10. CD 7.2. COMP – Compares two disk files Format COMP ambig1 ambig2 COMP A: B: COMP 9. DATE – Displays and sets Date 16 . BREAK – Allows program termination if you type ^ Break Format BREAK ON BREAK = ON BREAK 6.Changes the name of a disk drive Format ASSIGN A = C ASSIGN A=C. ASSIGN -.EXT 8. ATTRIB – Displays and changes read-only and archive attributes of a disk file Format ATTRIB +R ambig ATTRIB –R ambig ATTRIB +A ambig ATTRIB –A ambig ATTRIB +A + R ambig /S ATTRIB 4. CD (OR CHDIR) – Changes the current directory at the command prompt Format CD\ CD\EDIT CD SPELL CD .B=C Assign 3..* A:/S BACKUP C:\ambig A:/S/M 5. CHKDSK – Analyzes and summarizes the state of a disk Format CHKDSK C: CHKDSK C:/F CHKDSK C:/V CHKDSK PNAME.

DISKCOPY – Duplicates a complete flopp y disk Format DISKC OPY A: B: DISKCOPY A: A: 14. FDISK – Prepares a new hard disk Format FDISK 19.EXT D 15. MD (OR MKDIR) – Creates a subdirectory Format MD\EDIT 17 .EXT DEL ambig 12.EXT EDLIN PNAME. FIND – Searches for a pattern of letters in text Format FIND “string” PNAME.EXT 20. FASTOPEN – Starts programs quicker Format FASTOPEN C: FATOPEN C:=50 FASTOPEN C:/X 18.Format DATE DATE 6-9-89 11. LABEL – Changes the name of a disk Format LABEL B:RECEIPTS LABEL B: 22. DISKCOMP – Compares two floppy disks Format DISKC OMP A: B: DISKCOMP A: A: 13. ERASE – (See DEL) 16.EXE C: INSTALL = C:\UTIL\MOUSE. EXIT – Returns you to the DOS shell from the second command prompt Format EXIT 17.COM 21. EDLIN – Creates and alters a text file Format EDLIN EDLIN PNAME. DEL (OR ERASE) – Deletes disk files Format DEL PNAME. INSTALL – Installs resident programs on startup Format INSTALL = C:\DOS\FASTOPEN.

PRINT – Prints a disk file Format PRINT /D:PRN PRINT /D:COM1 PRINT PRINT/T PRINT PNAME.P MODE LPT1:=COM1 MODE LPT1 MODE N 25.1. MEM – Displays amount of total and available memory Format MEM MEM /PROGRAM 24. PROMPT – Changes the command prompt Format PROMPT $P$G PROMPT $P. RESTORE – Restores the hard disk from floppy disk backups 18 . 27.44m 29.EXT NEWNAME.EXT RUN ambig1 ambig2 31.EXT> 26.EXT/C 28. MODE – Configures the video screen and serial ports Format MODE COM1:2400. REPLACE – Selectively copies files Format REPLACE A:*.* C:/U 32.$D$G PROMPT PROMPT $E[ 0. RD (OR RMDIR) – Deletes a subdirectory Format RD\SUBDIR RD SUBIDR 30.23.C:\DOS PATH PATH. MORE – Stops scrolling when the screen is filled Format |MORE MORE <PNAME.37.8.N. REN (OR RENAME) – Renames a disk file Format REN OLDNAME. PATH – Establishes a search path for program execution Format PATH C:\DOS PATH D:\.46m $P$G$E[1.* C:/A REPLACE A:*.30.

EXT|MORE 40.SYS 256 DEVICE=VDISK. TREE – Displays subdirectory paths at the command prompt Format TREE 39. VERIFY – Verifies that a disk file is correctly written Format VERIFY ON 19 .COM SET SET SPOOLER = 48K 34.* /S RESTORE A: C:\*. SUBST – Establishes a subdirectory as a separate disk Format SUBST D: C:\EDIT SUBST D:/D 36. SORT – Sorts lines of a text file Format SORT <FILE1> FILE2 DIR|SORT /R+10|MOR E 35. TIME – Displays and allows alteration of time Format TIME TIME 13:7 38. VDISK – Establishes a RAM disk Format DEVICE=VDISK.EXT TYPE PNAME. VER – Displays DOS Version Format VER 42.Format RESTORE A: C:\*. SET – Changes and displays the current state of DOS features Format SET COMSPEC=C:\COMMAND. TYPE – Displays a text file on the video screen Format TYPE PNAME.* /S/N RESTORE A: C:\LOTUS\*.SYS 512/E DEVICE=VDISK.* /S/B:2-4-89 33.* /S RESTORE A: C:\*.EXT>PRN TYPE PNAME.SYS 512/X 41.* /S/A:2-4-89 RESTORE A: C:\*. SYS – Writes DOS system to disk Format SYS SYS C: 37.

3 Popularity and Success of UNIX 4.* /A XCOPY C:\DOS\*.1 Wh y you must know UNIX Today 4.1 File System 4.4 Operating System Services .2 Tree Structure 4.1.2 System Architecture 4.* /D:8-9-89 XCOPY C:\DOS\*.VERIFY = ON VERIFY 43.* /W XCOPY A:*.3.3 Directories 4.* /P XCOPY C:\DOS\*.3 FILE SYSTEM 4.* /M XCOPY C:\DOS\*.2.1 INTRODUCTION 4.3.1. XCOPY – Makes backup copies of files Format XCOPY C:\DOS\*.2.3.* /S 20 UNIX STRUCTURE 4. VOL – Displays the disk name and serial number Format VOL VOL A: 44.2 ARCHITECTURE OF UNIX 4.1.1 What Ex actly is UNIX 4.2 History of UNIX 4.3.

4. GETTING STARTED 4.4.4.4.3 Shell 92 .2 Logging In 4.1 Account and Password 4.4.

In 1969. 4. it made significant inroads into large Corporations and Government Organizations where its robustness established it on the operating system of choice for database work (Ex ample Oracle. Internet Service Providers use UNIX machines. and to allow users to share their data easily. Bell laboratories ended its participation in the project.Chapter 4 INTRODUCTION Objectives: After completing this chapter.1. 4. too man y for a sin gle person to master in a lifetime. you will the able to: • List 3 important phases of UNIX • Understand why UNIX popular • History of UNIX UNIX consists of a large number of ideas. it was considered a product for the Engineering and Scientific community. Even though the people say that UNIX was died. Later.2 History of UNIX In 1965. Sybase & Informix ) The Inter net is the third and most significant phase of the UNIX cycle. The goals of the Multics system were to provide simultaneous computer access to a large community of users. First reason.1. Many scientists later took part in the early development of the UNIX system. most servers on the net are UNIX machines. Bell Telephone Laboratories joined an effort with the General Electric Company and Project MAC of the Massachusetts Institute of Technology to develop a new operating system called Multics. if desired. to supply ample computation power and data storage.1 Why you must know UNIX Today UNIX had to grow through 3 important phases in its life cycle. 93 .

consistent interface to peripheral devices. Dennies Ritchie.3 Popularity and Success of UNIX Unlike DOS and Windows UNIX can be used by several users concurrently. change. and in 1973. In January 1983. and AT & T announced official support for System V. 94 . • It is a multi-user.1. and move to other machines. • It provide a simple. making it easier to write program that run on different Hardware implementations. and other s sketched a paper design of a file system that it evolved into an early version of the UNIX file system. • It uses a hierarchical File System that allows easy maintenance and efficient implement • It has a simple user interface that has the power to provide the service that users want. You can be perfo rming two tasks • simultaneously. the UNIX operating system was rewritten in C. making it easy to read. The UNIX is popular for the following reasons: • The system is written in a High Level Language. 4. Ritchie has developed a new lan guage called ‘C’. each user can execute several processes • simultaneously. Although this early version of the UNIX system held much promise. multiprocessor System. • UNIX has networking built in environment. • It hides the machine architecture from the user. understand. it could not realize its potential until it was used in a real project. • UNIX is a multitasking operating system. Bell Laboratories added several features to UNIX system III and called a new product UNIX System V.Later Ken Thompson.

Give three important reasons of UNIX 2.2 ARCHITECTURE OF UNIX Objectives: After completing this section. the operating system makes sure yo ur file isn’t written on top of an existing file. • It controls all input and output on the computer: When you delete a file.1: 1. the operating system goes ahead and eliminates a record of that file. . UNIX is not ver y friendly. That is. When you save a file.If you are migratin g from the DOS/ Windows environment. then you have quite a bit of mental preparation to do before you start feeling comfortable. An operating system performs many fun ctions: • It actually runs a program: When you enter a program‘s filename at the command line the operating system takes over by loading the program into your computers memory and runs it. you will be able to : • List Operating system functions • Draw UNIX system architecture 4. When UNIX system III released 3.1 What Exactly is UNIX UNIX is an operating system in the same way MS-DOS and OS/2 are Operating System. Name the Scientist who give the paper discover of or File system 4. Exercise 4.2.

and the kernel.2 System Architecture: UNIX carries out various functions through 3 separate. The system calls instruct the kernel .2. The hardware at the center of the diagram (see Figure1) provides the operating system with basic services. whether it’s a file created in a text processor or a driver used to send instructions to a pointer is contained in a file. Every thing on UNIX. viewing the system as a set of layers. The operating system is commonly called the system kernel or just the kernel.out H/W date Kernel wc ld ed grep Figure 1 depicts the high-level architecture of the UNIX system. is the part of UNIX you will actually • be using most of the time. the shell. • the File System tracks files and wher e they are located. providing common services to pro grams. • the shell or command-line interpreter.4. by invoking a defined set of system calls. Programs such as shell and editors (ed and vi) shown in the outer layers interact with the kernel. nroff sh cpp who CC comp as a. but closely integrated parts: the File System . The responsibilities are given below: • the kernel is responsible for all basic operating system functions. The operating system interacts directly with the hardware.

3. For example.1 File system The UNIX file system is characterized by • a hierarchical structure • consistent treatment of file data • the ability to create and delete files • dynamic growth of files • the protection of file data • the treatment of peripheral devices as files 4. the standard C compiler cc is in the outermost layer of the kernel: it involves a C preprocessor.3 FILE SYSTEM Objectives: After completing this section.3. regular files.to do various operations for the calling program and exchange data between the kernel and the program. have gradually become synonymous with the name “UNIX System”. Others application pro gr ams can build on top of low-level programs. 98 . assembler. Several programs shown the figure 1 are in standard system configurations and are known as commands.2 Tree Structure The file system is organized as a tree with a single root node called rod (“/”) (see figure 2) ever y non leaf node of the file system structure is a directory of files. or special device files. and loader. all separate lower-level programs.operating services 4. 4. Many application subsystems and programs that provide a high-level view of the system such as the shell. you will be able to: • List UNIX File system characters • Under stand file system hierarchy • List. and document preparation packages. The name of the file is given by a p ath name that describes how to locate the file in the file system hierarchy. and files at the leaf nodes of the tree are either directories. editors.

.a local lib lib ….. passwd etc gr oup init …. / usr include kra user pes ----….console spell div …. …… bin libc. tmp Figure 4. bin …… -----telnet sh ucb man bin csh …….2: Typical UNIX directory structure 99 tmp tmac lib troff troff .

and execute permission. Access permission can be set independently to control read. etc . waiting for the command to terminate before reading the next command line.A path name is a sequence of component names separated b y slash(/) characters. “/usr/ucb/telnet”. a command can be an executable file that contains object code produced b y compilation of source cod e (a C program for example). First. You may create files if directory permission is given. the system calls allow uses to write programs that do sophisticated operations and as a r esult. a command can be an executable file that contains a sequence of shell command lines. 100 . The shell searches for commands in a given sequence o f directories. Permission to access a file is controlled by access permissions associated with the file. changeable by user/invocation of the shell. the kernel of the UNIX system does not contain many functions that are part of the “kernel” in their systems. but the data contains the names of the files in the directory. a command can be internal shell command. Example: “/etc/password”. write. 4. a file group. The shell allows 3 types of commands.3. A full p ath names start is a slash (‘/‘) ch aracter and specifies a file that can be provided by staring at this file system root and traversing the file tree. Finally. “/home/Anand”. Generally. and every one else. Devices are also protected in the same way that regular files are protected. The shell usually execution a command syn chronously.3 Directories Directories are like regular files the system treats this data in a directory as a byte stream. Permission is given three classes of users: the file owner. Second.

disk drives.3.4.4 Operating System Services Among the services provided by the kernel so (Figure 1) are: • controlling the execution of process b y allowing their creation. Exercise 4. and communication. • Allowing processes controlled access to peripheral devices such as terminal tape drives. • Allocating main memory for an executing pro gr am • Allocating secondar y memory for efficient storage and retrieval of user data.3: 1) List at least 3 characters of UNIX file system 2) What is root? 3) Check whether the following statements True/False a) Leaf nodes are directories b) Leaf nodes are special device files 4) What is path give one example 5) Who allocate main memory for pro gram ex ecution 6) Who control access to peripheral devices 4. and network devices.4 GETTING STARTED Objectives: After completing the section. termination or suspension. • Scheduling process fairly for execution on the CPU. you will be able to: • Understand what is Account and Password • Understand One job of system administrator • Understand login procedure 101 .

The terminal do es not display what you type. Then press the <Enter> k ey.1 Account and password UNIX is security.2 Logging In Logging in is a simple procedure that tells the UNIX system who you are: $ login: The login prompt indicates that the terminal is available fo r some one to login (i.4.e connect). and can b e used only b y those persons who maintain an account with the computer system . you must set up your own user account.You can’t simply sit down at any terminal and start working as in DOS/Windows. This message also indicates that the previous user has “logged out” (disconnected).• Know what is shell • List different shells 4. If you are using a UNIX workstation. Enter your password. System administrator will grant you that authority.conscious. and given you a secret code called password that you have to enter when the system prompts you for it. T his code should be known to none except yourself. request you to enter the secret code (password) that was handed over to you by your administrator. 4.4. Enter your user name (or login name) and hit the <Enter> key after the string: $ login : Type user name <Enter> Password: The system now. He opens an account with the name (is known as login name/user name) for your use. Example: $ login: Anand <Enter> Password:*******<Enter> 102 .

4. the system flashes the followin g message Login incorrect Wait for login retry: If the login was successful. 1987.The system cross check this password and if it is right you will be presented with a login sequence like the following: Welcome to SCO system v/386 Login: Password: If you are logging onto a UNIX system V Release 5. 1986. you will be taken to the $ prompt. you are immediately thrust into your login shell. 1988 AT & T All Rights Reserved Last login : Friday March 09 10 :45 : 21 on term /12 If you make mistakes while typing simply press this <Enter> key one or two times till the login prompt reappears on the screen. $ This is equivalent of the C:\> 4. as in login into for all this users on your system. the Bourne shell. Information about this shell is usually contained in this file /etc/password. If you enter either of them in correctly. Developed by David Korn at Bell labs • Csh the C shell. Developed by Bill joy ( a founder of Sun Microsystems Inc) 103 . korn shell. • Ksh.3 Shell When you login your UNIX system. the sequence look like this: Login: Password: UNIX system V release AT & T 3B2 System id Copy right © 1984. No Command can be executed unless it obtains the clearance of the shell some popular shells one: • Sh. developed by stephen Bourne in 1979.

An extension of the Bourne shell. Developed by the Free Software Foundation.• Jsh the job shell.4: 1) What is an account? 2) What is login name or user name 3) What is Password 4) Explain how to login in UNIX 5) Ask your system administrator and create your own account and then login 6) Who sets the required environment when login is done 7) List different shells 8) Close the book and draw the kernel-sh ell relation ship diagram 104 . User User H/W Kernel Concepts User User Shell User Figure 4. • bash Bourne Again shell.3: shows this kernel-shell relationship Exercise 4.

Chapter 5 LINUX SYSTEM Structurre 5.1 INTRODUCTION 5.4 vi TEXT EDITOR 5.3.1.2.2 What is LINUX? 5.4 Using numbers with command 105 .4 Moving Copying and deleting files 5.3.3.1.2 Moving around the file 5.3 Searching for text 5.1 Starting with vi 5.1 Working with the Red Hat Linux File system 5.2 The login session 5.1 Logging in to Red Hat Linux 5.4.2.4.2.3 LINUX FILE SYSTEM 5.4.2.3.4 Checking Directories and permission 5.0 Using the vi Text editor 5.2 GETTING STARTED 5.3 Understanding File permission 5.5 Exiting the shell 5.2.4.3 The Shell interface 5.1 What you need? 5.1.3 Features of LINUX 5.4.2 Creating files and directories 5.

106 . To install everything. although you can install over a network instead. Torvalds started Linux by writing a kernel. you need a Personal Computer with the following general configuration: • An Intel 80386.1 What you need? To work with LINUX. you need at least a 3. and run many programs at once (multitasking). • A CD-ROM drive is recommended for installation. PC configuration needed for LINUX 2.5. you will be able to: 1. Know what is LINUX 3. while Microsoft flooded the world with personal computers running DOS and Windows operating systems.6GB of space. To run the GNOME or KDE desktop. support many users at once (multiuser). Features of LINUX 5. Pentium. power users demanded mor e from an operating system. • You need 500MB of hard disk space for a typical installation.5-inch floppy disk drive and a network connected to a computer that has the Red Hat Linux software packages available.1. you need about 1.1 INTRODUCTION Objectives: After completing this chapter. which is the heart of the operating system. DOS and Windows didn’t cut it. • At least 16MB of RAM. In the 1980s and 1990s. Red Hat recommends 48MB. or compatible CPU.2 What is LINUX? LINUX is a free Operating System that was created by Linus Torvalds when h e was a student as the University of Helsinki in 1991. although 24MB or more is recommended.1. For that. 5. They ached for system that could run on networks.

sound cards. • Multitasking –You can have many programs running at the same time in LINUX. and serial devices. A variety of software packages are available that enable you to use Linux as a print server. 107 . removable disks (such as Zip drives).5.) • Hardware support –You can configure in support for almost every type of hardware that can be connected to a computer. There are dozens of desktop managers you can choose from.25 (a packet-switching network type that is popular in Europe). Ethernet. such as IPX (for Novell networks) and X. at the same time. Linux offers supp ort fo r a variety of Local Area Network (LAN) boards. can have programs running in the background. Oth er protocols. Many of these system processes mak e it possible for LINUX to work as a server. menus. are also available. • Networking connectivity –To connect your Linux system to a network. but focuses on Gnome and KDE.1. • On top of X. window frames. (Red Hat provides several desktop managers. X handles the functions of opening X-based GUI applications and displaying them on X server process (the pro cess that manages your screen. itself.3 Features of LINUX: • Multi user –Not only can you have many user accounts available on a LINUX system. but you can also have multiple users logged in and working on the system. • Graphical User Interfa ce (X Window System) –The powerful framework for working with graph ical applications in Linux is referred to as the X Window system (or simply X). CD-ROMs. and colors). tape devices. the most popular protocol TCP/IP (which is used to connect to the Internet). you use an X-based window manager to provide the specific look-and-feel of your GUI (icons. There is support for floppy disk drives. it also means that Linux. modems. mouse. and most anything else you can think of. video cards. Besides meaning that you can have lots of programs going at once. • Network service-Providing networking services to the client computers on your LAN or to the entire Internet is wh at Linux does best. and keybo ard).

news server. web server. Give the general configuration of PC to run LINUX operating system. a wide range of freeware. Mention at least five important features of LINUX system.2 GETTING STARTED Objectives: After completing this section. Exercise 5. The shell is powerful. you will be able to: • Logon to LINUX system • Understand login session • Understand shell interface • List existing shells This section presents a view of Red Hat Linux from the shell. or workgroup server. complex. FTP server. mail server. Who wrote LINUX operating system. 4.file server. and almost completely unintuitive. Is LINUX is a free software? 3. T he shell is a command line interpreter that lets you access some of the most critical Red Hat Linux tools. • Application support.Because of compatibility with POSIX and several different application programming interfaces (APIs). 5. 108 . 2.1: Practice the following: 1.

you will see a login prompt similar to this: Red Hat Linux release 6. Other users typically have home directories in the /home directory.2. with each having slightly different features.2 The login session As you log on. Logging in identifies you as a particular user. This chapter also describes the shell environment and helps you tailor it to your needs. 109 .10-3smp on an i686 l ocal host login: The graphical login is typically your entry into the X Window System graphical user interface (GUI).1 (Hedwig) Kernel 2. you start by logging in. The root user’s home directory in Linux is usually root(/). and file system from the shell. even if you are the only person using the computer.1 Logging in to Red Hat Linux Because Red Hat Linux was created as a multi-user computer system. 5. The window manager provides the specific look and feel of the GUI. While X provides a framework for a GUI th at lets you run applications. it enables you to choose from many different window managers. Some of the features that make up your user environment are: • A home directory: The home directory identifies a location on the computer’s hard disk where you can save and p rotect the files that you need.This section is your guide to loggin g in and working with Linux system commands. After the computer has been turned on and the op erating system has started. Red Hat Linux starts up a user environment that is unique to your user account. 5.2. • A graphical configuration: Most GUIs used with Linux are based on X Windows system (often referred to simply as X). The bash shell (which stands for Bourne Again Shell) is most commonly used with Linux.2. processes. • A shell configuration: There are several shells available for use with Linux.

the first thing you see is the shell prompt.4 Checking Directories and permissions When you first log in to Linux.Once the login process is complete. type the echo command. The default prompt for a user is simply a dollar sign: $ The default prompt for the root user is a pound sign: # 5. 5. ls.2. you begin with your home directory as the current directory. typ e the pwd command. either a shell or a GUI is started automatically. the current or working directory is /urs/bin. When you request to open or save a file.2. To get back to your home directory. To find out what your current directory is. 110 . $ cd The UNIX system commands cd. To find out the name of your home directory. $ pwd /usr/bin In this example. the home directory is /home/Anand.3 The shell interface Assuming that you are using a shell interface. which work in the same way in L INUX system. your shell uses the current directory as the point of reference. followed by the $HOME variable: $ echo $HOME /home/Anand In the above example. you can simply type the change directory (cd) command.

5. you either type exit or press Ctrl+D. 6.5 Exiting the shell To exit from the shell when you are done. you will be able to: • • • • • • • 111 Know the hierarchy of LINUX file system Create your own directory Use ls command Use cd command Use chmod command Understand file permissions Move files from one directory to another directory . 3. Type logout and see the effect..5. type logout to exit the shell. 4.2. When you login into your account. Use pwd command to know your current directory. command and then use pwd to know where you are. What message will appear on the screen when the LINUX system on. Exercise 2: Practice the following: 1. Type exit from login mode and watch the difference with resp ect to logout. which prompt appears. Type echo $HOME command and then use pwd. 2. 7.3 LINUX FILE SYSTEM Objectives: After completing this section. Use cd . If you are existing from your login shell (the shell that started when you first logged in). 5.

and CD-ROM (cd*). such as /bin. /home. which is rep resented by a single slash (/). • /mnt. to name a few. • /home-Contains directories assigned to each user with a login account. bin/ dev/ etc/ home/ ro ot/ tmp/ … mary/ Anand/ tom/ memos/ briefs/ personal/ Figure 3-1 illustrates how the Linux file system is organized as a hierarchy. hard disks (hd*). RAM (ra m*). such as remote file systems and removable devices (cdrom. floppy.Contains common Linux user commands. Below that is a set of common directories in the Linux system. can contain subdirectories.5. 112 . and /tmp. Each directory can contain files. as well as directories added to the root. Some of the Red Hat Linux directories that may be of interest to you include the following: • /bin. /dev. floppy disks (fd*). Files are organized within a hierarchy of directories. • /dev. These include terminal devices (tty*). At the top is the root directory.Provides a locatio n for mounting devices.Contains files representing access points to devices on your systems. as well as other directories.3.) • /etc-Contains administrative configuration commands and files. Each of those directories. /lib. sort. (Users normally access these devices directly through the device flies. such as ls.1 Working with the Red Hat Linux File system The Red Hat Linux file system is the structure in which all the information on your computer is stored. date and chmod. and so on).

games.3. libraries (lib). and a variety of other user and administrative commands and files. 2. type pwd. • /sbin. The files systems in the DOS or MS Windows operating systems differ from Linux file structure. First. Create a new directory called test by using mkdir command in your home directory as follows: $ mkdir test 4. Check the permission of the directory by typing: 113 . To make sure that you got to your home directory. moving among your directories. simply type cd.2 Creating files and directories You will use some of these commands in the file creation process: • cd – Change to another current working directory. • /tmp. and setting appropriate file permissions: 1. • mkdir – Create a directory • chmod – Change the permission on a file or directory • ls – List the contents of a directory. To do this. When you do this. • /usr-Contains user documentation. graphical files (X11). The following procedure steps for creating directories within your home directory. go to your home director y.• /root-Represents the root user’s home directory.Contains administrative commands and daemon processes.Contain temporary files used by applications. you get the following response (reflects your home directory): $ pwd /home/Anand 3. 5. • pwd – Print the name of the current working directory.

1 Anand sales 4983 Jan 18 22:13 ch3 drwxr-xr-x 2 Anand sales 1024 Jan 24 13:47 test 114 . the next three apply to the owner’s group.3 Understanding File Permissions Permissions associated with files and directories in Linux (exactly similar to UNIX) were designed to keep users from accessing other users’ private files and to protect important system files. The nine bits assigned to each file for permissions define the access that you and others have to your file. and the file was most recently modified on January 24 at 12:17 p.3. make the text directory your current directo ry as follows: $ cd test 5. Type the following. You can see the permission for any file or director y b y typing the ls – ld name command. The name file or directory will appear as those shown in the example below: $ ls .ld ch3 test -rw-rw-r-. the owner is Aanand.m.$ ls . 6. and the last three apply to all others. $ chmod 700 test This command changes the permissions of the director y to give you complete access and everyone else no access at all. (The new permissions should read like rwx --. Suppose that you want to prevent everyone else who uses this computer from using or viewing the files in this directory. Permission bits appear as rwxrwxrwx.ld test drwxr-xr-x 2 Anand sales 1024 January 24 12:17 test Notice that this listing says that test is a directory (d). Next. The permissio ns for the directory is rwxr-xr-x. The first three bits apply to the owner’s permission. The coming section explains what these permissions are. 5.---). the group is sales.

b y def ault it is given the permission: rw. use the cp command. For example: $ umask 022 5.r--.Here are some examples of how to change permission on a file and what the resulting permission would be: chmod 777 file names rwx rwx rwx chmod 755 file names rwx r-x r-x chmod 644 file names rw. use the rm command. Here are some examples: $ mv abc def $ mv abc ~ $ cp abc def $ cp abc ~ $ rm abc $ rm * 115 . To copy a file one location to another.4 Moving copying and deleting Files Commands for moving.--.r-. copying. A directory is given the permission rwx r-x r-x. Type umask to see what your umask values.--When you try to create a file. To remove a file. These default values are determined by the value of umask. use the mv command.r-. and deleting files are fairly straight forward.3. To Change the location of a file.r— chmod 000 file names --.

4 vi TEXT EDITOR Objectives: After completing this section. But once you know it.0 Using the vi Text Editor The vi editor is difficult to learn at first.4. you will be able to edit and move around files quickly and efficiently. you will be able to: • • • • Open a file in vi editor Understand various vi commands Move around the file Search for text 5. The vi in LINUX System is exactly similar vi in UNIX system. 5. type the followin g command: $ vi /tmp/test If this is a new file. you should see something similar to the following: ~ 116 .1 Starting with Vi To open a file called /tmp/test.5.4.

use h (left). Repeat that a few times until you have a few lines of text. 0 (Zero) Moves the cursor to the end of the current line. Type a few words and press Enter. L Moves the cursor to the lower-left corner of the screen (last line on the screen). i Insert: After you typ e i you can input text that starts to the left of the cursor. b Moves the cursor to the beginning of the previous word. Vi commands for deleting text: x Deletes the character und er the cursor. left. or k (up) to move the cursor. M Moves the cursor to the first character of the middle line on the screen. respectively. w Moves the cursor to the beginning of the next word. $ Moves the cursor to the end of the current line. type either of the following input commands: a Add: After you type a you can input text that starts to the right o f the cur sor. down. If you prefer to keep you fingers on the keyboard. or right in the file one character at a time. j (down).~ ~ ~ ~ “ /tmp/test” [New File] To start out. X Deletes the character directly before the cu rsor. When you are done typing press Esc. I (right). H Moves the cursor to the upper-left corner of the screen (first line on the screen). Try moving around within that text with the following commands: Arrow keys Use the arrow keys to move up. 117 . To move left and right you can also use Backspace and the spacebar.

:w Save the current file but continue editing.) 5. This works only if you don’t have any unsaved changes. you can also use metacharacters.2 Moving around the file Other ways o f moving around a vi file.dw Deletes from the current character to the end o f the current word. / hello Searches forward fo r the word hello. use either the slash (/) or the question mark (?) character. Several ways of saving and quitting the file follow: ZZ Save the current changes to the file and exit from vi. 118 . Ctrl + b Pages back. :q Quit the current file. Ctrl + f Page ahead. d$ Deletes from the current character to the end of the current line. d0 Deletes from the previous character to the beginning of the current line. 5.4. 1G Go to the first line of the file. one page at a time. ? goodbye Searches b ackwards for the word goodbye.4.3 Searching for text To search for the next occurrence of text in the file. one pages at a time. Ctrl + d Page ahead ½ page at a time Ctrl + u Pages back ½ page at a time G Go to the last line of the file. :wq Same as ZZ. you could use any number to go to that line number in the file. :q! Quit the current file and DON’T save the changes you just made to the file. Within the search. (Instead of I.

/ The * f oot Searches forward for a line that has the word The in it and also. Here are some examples: 3dw Deleting the next three words.4 Using numbers with commands You can precede most Vi commands with numbers to have the command repeated that number of times. 5cl Changes the next five letters (i. Remember that case does matter in Linux.4.e. . 5. 12j Moves down 12 lines. the word foot. after that at some point. so using brackets is one way to search for words that could have different capitalization: The vi command was originally based on the ex editor. removes the letters and goes into input mode).. ? [ pP]rint Searches backward for either the word p rint or print.

Sign up to vote on this title
UsefulNot useful