Unit 1 - Introduction of Unix OS PDF
Document Details
Naran Lala College
Chandrakala J. Chetri
Tags
Related
- Desislav Andreev, Stanimir Lukanov - C++ Programming for Linux Systems_ Create robust enterprise software for Linux and Unix-based operating systems-Packt Publishing (2023)-1-364-375.pdf
- Server Operating Systems PDF
- Unix Shell und Bash PDF
- UNIX Lectures.pdf
- Operating Systems Fundamentals PDF
- Guide to UNIX Using Linux PDF
Summary
This document provides an introduction to Unix operating systems, focusing on core concepts, history, and various topics like features and differences from Windows. It's targeted towards undergraduate computer science students.
Full Transcript
Unit 1 –Introduction of Unix OS Unix & Shell Programming Naran Lala College of Professional & Applied Sciences Chandrakala J. Chetri Unix & Shell Programming – Unit 1 Notes Unit 1 – Topics Unit 1 Topics 1.1...
Unit 1 –Introduction of Unix OS Unix & Shell Programming Naran Lala College of Professional & Applied Sciences Chandrakala J. Chetri Unix & Shell Programming – Unit 1 Notes Unit 1 – Topics Unit 1 Topics 1.1 Features 1.2 System Structure & Architecture of Unix OS 1.3 Shell & its Features 1.4 Kernel & its Structure CJC, Naran Lala College, BCA Dept Page 2 Unix & Shell Programming – Unit 1 Notes History of Unix OS In 1965 , three laboratories : Massachusetts institute of technology(MIT),General Electrical and Bell laboratories of AT & T worked on a joint venture project which intended to develop a multi-user operating system that provide remote access to the computer as well as shared data of the computer. To accomplish this task, they developed an OS called MULTICS (MULTiplexed Information and Computing Service). MULTICS had many problems, So Ken Thomson developed an operating system called UNICS or UNiplexed Information Computing System during the latter part of 1969. UNICS was developed completely in assembly language and so it was not portable. To achieve portability, Thomson considered implementing the system in high level language which leaded to the development of ‘c’ language by Ritchie. In 1970, Ken Thompson joined by Dennis Ritchie and renamed UNICS as Unix. By 1973, UNIX was completely rewritten in C langugage which inherited the portability feature of C language, so that the system was now portable to other hardware platforms with nominal effort. CJC, Naran Lala College, BCA Dept Page 3 Unix & Shell Programming – Unit 1 Notes Unix is a multiuser and multitasking operating system. It is said to be the first OS designed in C programming language. The basic design philosophy of UNIX is to provide simple, powerful tools that can be combined to perform complex tasks. It features a command-line interface that allows users to interact with the system through a series of commands, rather than through a graphical user interface (GUI). The main aim behind Unix was to have an OS that would support the development of software tools for the new generation of computer hardware. Difference between Unix OS and Windows OS Unix OS Windows OS UNIX is an open source (free download) Windows is not an open source (paid one) UNIX has very high security system Windows has low security system UNIX is a command based operating Windows is not a command based system operating system The file system is arranged in hierarchical The file system is arranged in parallel manner manner UNIX is not a user friendly Windows is a user friendly Free office Tools (such as excel, PowerPoint Pay for MS Office and others) Low Hardware cost High Hardware cost Customizable add features Not customizable CJC, Naran Lala College, BCA Dept Page 4 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 5 Unix & Shell Programming – Unit 1 Notes Features of Unix OS:- 1. Multi-User Support 2. Multi-Tasking 3. Communication 4. Security 5. Portability 6. Scalability 7. Open Source 8. Command Line Interface (CLI) 9. Programming Tools & Pattern Matching 10. Networking 11. Accounting 12. Windowing System CJC, Naran Lala College, BCA Dept Page 6 Unix & Shell Programming – Unit 1 Notes 1. Multi-User Support Unix was developed to support multiuser systems from the beginning. UNIX allows multiple users to simultaneously access the same system and share resources (such as hard disk, memory, printer, scanner, CPU, etc…) of main computer (server / host machine). In this environment, different terminals are given to the users who want to access resources of main computer. Terminals are of different types, some are as follows: Dumb Terminal : ▪ Consists of only a Keyboard & a Monitor; No Memory or Disk; can’t operate as an independent machine. ▪ Must connect to the host machine. Terminal Emulation : ▪ Consists of a Keyboard & a Monitor with its own microprocessor, memory and HDD linked to Host machine via cable. CJC, Naran Lala College, BCA Dept Page 7 Unix & Shell Programming – Unit 1 Notes ▪ User runs terminal emulation s/w (VTERM, PUTTY, XTALK, etc…) to connect with host machine; if connection is established then it works as a dumb terminal. Dial-up Terminal : ▪ If the host machine is at remote location then dial-up terminal is used. 2. Multi-Tasking This feature enables user to carry out more than one job at the same time. The UNIX operating system allows you to launch several tasks or processes from the same terminal, with one running in the foreground and the other in the background. You can switch jobs between background and foreground, suspend or even terminate them. 3. Communication This feature allows user to communicate with users. It supports various communication facilities provided using the write command, mail command, talk command, etc. 4. Security UNIX has a robust security model that includes file permissions, user accounts, and network security features. The OS is considered safe from viruses. Installation of an anti-virus is not necessary for it. Unix provides three types of securities:- 1. System Level Security: In Unix, every user has been allocated login id & password. When the system administrator opens an account for user, an entry is created in a system password file, called etc/password. So to access the resources of the Unix system, user has to log in first. CJC, Naran Lala College, BCA Dept Page 8 Unix & Shell Programming – Unit 1 Notes Only authorized user can access the system. 2. File Level Security: In Unix, everything is treated as file. Even directories or devices are also considered as file. There are read, write and execute permissions to each file, which decide who can access a particular file, who can modify it and who can execute it. 3. Data Level Security: Lastly, there is file encryption. Encryption utility encodes your file into an unreadable format, so that even if someone succeeds in opening it, your crucial information is safe. 5. Portability Because a large percentage of the UNIX operating system is written in the C language and only a tiny portion is coded in assembly language for specific hardware, it ensures the transfer of code to any computer system. The code can be changed and compiled on a new machine. UNIX can run on a wide variety of hardware platforms, from small embedded systems to large mainframe computers. 6. Scalability The Unix operating system is also known for its scalability. Its ability to handle huge amounts of data traffic without impacting the system's performance makes it a good choice for applications (whether it be of small personal computers or large-scale corporation systems). 7. Open Source LINUX OS (clone of UNIX) was founded by Linus Benedict Torvalds in 1991 is open- source and freely available to the community for use and customization. CJC, Naran Lala College, BCA Dept Page 9 Unix & Shell Programming – Unit 1 Notes It has an open architecture; one can add to the tool kit by simply writing a program and storing the executable in a separate area in the file system. A separate device can also be added by creating a file for it. Modification of the system is easy as the source code is always available freely 8. Command Line Interface (CLI) Unix comes with a powerful command line interface that allows users to interact with the system by typing commands into a terminal window via a shell program (Command Interpreter). The CLI offers multiple tools for text processing, programming, networking, and scalability, thus making it an essential tool for data analysis. With the Unix CLI, the user can also automate tasks by designing scripts that can be executed automatically. 9. Programming Tools & Pattern Matching Unix is highly programmable; it was designed for programmer, not a casual end user. The Unix shell programming language has all the necessary tools like control structures, loops and variables. Unix has a unique and powerful pattern-matching feature that allows users to search for and modify text based on specific patterns. Pattern matching can be implemented in various Unix commands like grep, sed, awk, etc. 10. Networking The networking capabilities of Unix have been improvised year after year and have now become highly advanced, thus making it an ideal choice for network-intensive applications. CJC, Naran Lala College, BCA Dept Page 10 Unix & Shell Programming – Unit 1 Notes The robust networking stack of Unix can handle a wide range of protocols and services and can be used for complex servers. 11. Accountability UNIX maintains track of the jobs that the user creates. This function improves system performance by monitoring CPU use and verifying disk space. It allows you to keep track of how much disk space each user uses, and the disk space may be regulated by each other. You can set a distinct disk quota for each user. 12. Windowing System UNIX has a pretty weak UI i.e. CLI. Faced with competition from other OS (Ms. Windows), Unix had to come up with its own GUI. Eg. Linux : It has graphical user interface (screenful of objects in the form of menus, icons, buttons and dialogue boxes) along with command line interface. CJC, Naran Lala College, BCA Dept Page 11 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 12 Unix & Shell Programming – Unit 1 Notes 1.2 System Structure (Architecture) Unix System Organization Unix is a layered operating system. Major components of Unix operating System (architecture) are : Hardware Layer Kernel Shell Utilities (Commands & Libraries) User Applications / Application Layer CJC, Naran Lala College, BCA Dept Page 13 Unix & Shell Programming – Unit 1 Notes Layer 1 : Hardware The lowest layer of the Unix architecture is the hardware layer, which provides the physical components of the computer, such as the CPU, memory, disk drives, etc… It contains the hardware-related information required for the functioning of the UNIX environment. CJC, Naran Lala College, BCA Dept Page 14 Unix & Shell Programming – Unit 1 Notes Division of Labor : Kernel and Shell The kernel and shell are the heart and soul of the operating system. Kernel is the central core of the operating system that interacts directly with the hardware of the system. Shell is the interface between User and Kernel. Users’ interact directly with Shell. Layer 3 : Shell Shell is a command interpreter which interprets the commands typed by user at the terminal. The shell provides a command-line interface that allows users to interact with the system. When any user logs in successfully to the Unix system, a shell is allocated to that user. It offers a prompt through which user issues a command to the Unix system. It translates user’s commands into functions understandable by Kernel which ultimately executes them. Shell uses the services of the Kernel to perform jobs of the user through a set of functions called as system calls. Layer 2 : Kernel Kernel is an important component of Unix OS. It resides between hardware and shell. Kernel is heart of Unix which interacts with actual hardware in machine language. CJC, Naran Lala College, BCA Dept Page 15 Unix & Shell Programming – Unit 1 Notes Kernel performs low-level task like device management, memory management, process management, file system management, security management, etc… Kernel program is usually stored in file called ‘Unix’ whereas shell program is stored in a file called ‘sh’. For each user working with unix at any time, different shell programs are running. So there may be several shells running in memory but only one kernel. Collections of routines is mostly written in C. It’s loaded onto memory on system boot. User programs that need to access the hardware use the services of the kernel via use of system calls and the kernel performs the job on behalf of the user. Overall, kernel is responsible for managing the fundamental resources of OS and provides a stable & secure environment for applications and commands to run. Layer 4 : Utilities (Commands & Libraries) Utilities are tools & programs provided by OS to interact with the system & perform various tasks. These collection of programs performs system functions and referred to as ‘Commands’. The programs interact directly with the kernel using system calls and are executed with the help of Compiler (CC). Sometimes assembler, linker, loader, are also required. CJC, Naran Lala College, BCA Dept Page 16 Unix & Shell Programming – Unit 1 Notes These commands can be invoked through shell & are categorized into several types. E.g. File management commands, text processing commands, system administration commands, network commands & shell built-in commands. There are over 250 standard commands plus numerous others provided by third- party software. Layer 5 : Applications The top layer of the Unix architecture is the application layer, which includes all the user-level programs that runs on the system. The programs are written by system administrator, professional programmers or users known as applications. Applications can be developed using a wide range of programming languages, including C, C++, Python, Java, and Perl. These applications can be accessed by a command on command line. It’s capable of executing external applications like word processors, graphics programs, email system, text editors, etc… They provide an extended capability to the system. CJC, Naran Lala College, BCA Dept Page 17 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 18 Unix & Shell Programming – Unit 1 Notes Shell It is the most widely used utility programs on all Unix systems that processes our requests. An OS starts a shell for each user when the user logs in or opens a terminal or console window. It is known as the command interpreter because it interprets the commands and passes it to kernel for execution. The shell is also responsible for returning the results of the commands to the terminal, a file, or another device. CJC, Naran Lala College, BCA Dept Page 19 Unix & Shell Programming – Unit 1 Notes Types of Shell The shell runs like any other program under the Unix system. Hence one shell program can replace the other, as it would call any other program. Due to this feature, a number of shells have been developed in response to different needs of users. In UNIX, users are free to select a shell of their choice. CJC, Naran Lala College, BCA Dept Page 20 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 21 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 22 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 23 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 24 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 25 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 26 Unix & Shell Programming – Unit 1 Notes Features / Functions of Shell The primary advantages of interfacing to the system through a shell are as follows: 1. Command Interpretation 2. Shell scripts 3. Input / Output redirection 4. Piping Mechanism 5. Wildcard substitution in filenames (pattern-matching) 6. Background processing 7. Customized Environment 8. Programming Ability 1. Command Interpretation The shell allows users to execute commands and launch applications (external applications) by typing in specific commands or running scripts. 2. Shell scripts Shell script is a file that contains group of Unix commands combined together and executed as individual files. It is known as shell program. 3. Input / Output redirection I/O redirection is a function of the shell that redirects the output from a program to another destination other than terminal. This way, user can save output results from a command to a file and redirect it to printer, another terminal on network or even another program. CJC, Naran Lala College, BCA Dept Page 27 Unix & Shell Programming – Unit 1 Notes Similarly, the shell can make a program that accepts input from sources other than keyboard. 4. Piping Mechanism Piping mechanism allows the standard output of one command to be used as standard input for another Unix command. Using piping, programs that perform simple functions can easily be linked to perform more complex functions, minimizing the need to develop new programs. 5. Wildcard Substitution in filenames (pattern-matching) Automatically produces a list of file names on a command line using pattern- matching characters. Carries out commands on a group of files by specifying a pattern to match, rather than specifying an actual file name. 6. Background Processing A Multi-tasking facility allows user to run command in the background. Sets up lengthy tasks to run in the background, freeing the terminal for concurrent interactive processing. When a background task is completed, the user is notified. 7. Customized Environment The shell provides mechanisms for customizing the user's environment, such as setting environment variables, defining aliases and creating shell functions. CJC, Naran Lala College, BCA Dept Page 28 Unix & Shell Programming – Unit 1 Notes The user can control the behavior of the shell, as well as other programs and utilities by storing data in variables. 8. Programming ability The shell includes features that allow it to be used as programming language. These programming features can be used to build shell scripts that perform complex operations CJC, Naran Lala College, BCA Dept Page 29 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 30 Unix & Shell Programming – Unit 1 Notes Kernel & its Structure (Architecture) The Unix OS has three levels : User level, Kernel level and hardware level CJC, Naran Lala College, BCA Dept Page 31 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 32 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 33 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 34 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 35 Unix & Shell Programming – Unit 1 Notes CJC, Naran Lala College, BCA Dept Page 36 Unix & Shell Programming – Unit 1 Notes Functions of Kernel A Kernel is the central component of an Operating System. The Kernel is also said to be the heart of the Operating System. It is responsible for managing all the processes, memory, files, etc. The Kernel functions at the lowest level of the Operating System. It acts as an interface (bridge) between the user-level application (software) and the hardware. Therefore, the communication between the software and the hardware is done via the Kernel. The main functions that the Kernel performs are as follows: 1. Process Management 2. Memory Management 3. Device Management 4. Interrupt Handling 5. Input Output Communication 1. Process Management The creation, execution, and termination of processes keep on going inside the system whenever a system is in the ON mode. A process contains all the information about the task that needs to be done. So, for executing any task, a process is created inside the systems. At a time, there are many processes which are in live state inside the system. The management of all these processes is very important to avoid deadlocks and for the proper functioning of the system and it is handled by the Kernel. 2. Memory Management CJC, Naran Lala College, BCA Dept Page 37 Unix & Shell Programming – Unit 1 Notes Whenever a process is created and executed, it occupies memory, and when it gets terminated, the memory can be used again. But the memory should be handled by someone so that the released memory can be assigned again to the new processes. This task is also done by the Kernel. The kernel keeps track about which part of the memory is currently allocated and which part is available for being allocated to the other processes. 3. Device Management The Kernel also manages all the different devices which are connected to the system, like the Input and Output devices, etc. 4. Interrupt Handling While executing the processes, there are conditions where tasks with more priority need to be handled first. In these cases, the kernel has to interrupt in-between the execution of the current process and handle tasks with more priority which has arrived in between. 5. I/O Communication As the Kernel manages all the devices connected to it, so it is also responsible for handling all sorts of input and output that is exchanged through these devices. So, all the information that the system receives from the user and all the output that the user is provided with via different applications is handled by the Kernel. CJC, Naran Lala College, BCA Dept Page 38