You are on page 1of 14

UNIX

Unit 1

Unit 1
Structure 1.1 Introduction Objectives 1.2 What is an Operating System? 1.3 A brief history of unix. 1.3.1 What is Linux? 1.4 Structure of an Unix OS 1.5 Preview of few Unix commands 1.5.1 General format of UNIX commands 1.5.2 Simple UNIX commands

Overview of Unix

1.5.3 Logging into (and out of) UNIX Systems 1.5.4 Changing your password 1.6 Summary

1.1 Introduction
This unit introduces the concept of operating system. It describes in brief the architecture of an operating system which would help to understand the subject intuitively. It emphasizes on the Unix OS component kernel, the shell, its various types. Objectives: After studying this unit, you should be able to explain:

The concept of an operating system. The internal architecture of an operating system. The evolution of the UNIX operating system into two broad schools (BSD and SYSV) .

UNIX Operating system : The Kernel and Shell. How to log into (and out of) UNIX and change your password. The general format of UNIX commands.
Page No. 1

Sikkim Manipal University

UNIX

Unit 1

1.2 What is an Operating System?


An operating system (OS) is a resource manager. It takes the form of a set of software routines that allow users and application programs to access system resources (e.g. the CPU, memory, disks, modems, printers network cards etc.) in a safe, efficient and abstract way. For example, an OS ensures safe access to a printer by allowing only one application program to send data directly to the printer at any one time. An OS encourages efficient use of the CPU by suspending programs that are waiting for I/O operations to complete to make way for programs that can use the CPU more productively. An OS also provides convenient abstractions (such as files rather than disk locations) which isolate application programmers and users from the details of the underlying hardware.

Fig. 1.1: General operating system architecture

Fig. 1.1 presents the architecture of a typical operating system and shows how an OS succeeds in presenting users and application programs with a
Sikkim Manipal University Page No. 2

UNIX

Unit 1

uniform interface without regard to the details of the underlying hardware. We see that:

The operating system kernel is in direct control of the underlying hardware. The kernel provides low-level device, memory and processor management functions (e.g. dealing with interrupts from hardware devices, sharing the processor among multiple programs, allocating memory for programs etc.)

Basic hardware-independent kernel services are exposed to higher-level programs through a library of system calls (e.g. services to create a file, begin execution of a program, or open a logical network connection to another computer).

Application programs (e.g. word processors, spreadsheets) and system utility programs (simple but useful application programs that come with the operating system, e.g. programs which find text inside a group of files) make use of system calls. Applications and system utilities are launched using a shell (a textual command line interface) or a graphical user interface that provides direct user interaction.

Operating systems (and different flavours of the same operating system) can be distinguished from one another by the system calls, system utilities and user interface they provide, as well as by the resource scheduling policies implemented by the kernel. Operating systems examples: windows, MAC, Linux, UNIX.

1.3 A Brief History of UNIX


UNIX has been a popular OS for more than two decades because of its multi-user, multi-tasking environment, stability, portability and powerful networking capabilities. What follows here is a simplified history of how UNIX has developed
Sikkim Manipal University Page No. 3

UNIX

Unit 1

Fig. 1.2: Simplified UNIX FamilyTree

Operating System Name Multiplexed Information Computing System MULTICS UNICS (Uniplexed Information Computing System) UNIX kernel in C and and

Founders

Year

Organization

1960s

General Electric, MIT Labs and Bell

1960s

General Electric, MIT Labs and Bell

Dennis Ritchie

1973.
Page No. 4

Sikkim Manipal University

UNIX

Unit 1

SYSV (System 5) and BSD (Berkeley

Dennis Ritchie

1978

University California Berkeley

of at

Software Distribution)

1.3.1 What is Linux? Linux is a free open source UNIX OS for PCs that was originally developed in 1991 by Linus Torvalds, a Finnish undergraduate student. Linux is neither pure SYSV or pure BSD. Instead, incorporates some features from each (e.g. SYSV-style startup files but BSD-style file system layout) and aims to conform with a set of IEEE standards called POSIX (Portable Operating System Interface). To maximise code portability, it typically supports SYSV, BSD and POSIX system calls (e.g. poll, select, memset, memcpy, bzero and bcopy are all supported). The open source nature of Linux means that the source code for the Linux kernel is freely available so that anyone can add features and correct deficiencies. This approach has been very successful and what started as one person's project has now turned into a collaboration of hundreds of volunteer developers from around the globe. The open source approach has not just successfully been applied to kernel code, but also to application programs for Linux. As Linux has become more popular, several different development streams or distributions have emerged, e.g. Redhat, Slackware, Mandrake, Debian, and Caldera. A distribution comprises a prepackaged kernel, system utilities, GUI interfaces and application programs.

Sikkim Manipal University

Page No. 5

UNIX

Unit 1

Redhat is the most popular distribution because it has been ported to a large number of hardware platforms (including Intel, Alpha, and SPARC), it is easy to use and install and it comes with a comprehensive set of utilities and applications including the X Windows graphics system, GNOME and KDE GUI environments, and the StarOffice suite (an open source MS-Office clone for Linux). Self Assessment Questions I(SAQ I) 1) The operating systems _________is in direct control of the underlying hardware. 2) UNIX is multi-user, multi-tasking OS. (True/False) 3) UNIX OS was entirely developed in _______programming language. 4) Operating system is a resource manager. (True/False).

1.4 Structure of Unix Operating system


The kernel

Sikkim Manipal University

Page No. 6

UNIX

Unit 1

The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls. As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands. Amongst the functions performed by the kernel are:

managing the machine's memory and allocating it to each process.


Page No. 7

Sikkim Manipal University

UNIX

Unit 1

scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible.

organising the transfer of data from one part of the machine to another. accepting instructions from the shell and carrying them out. Enforcing the access permissions that are in force on the file system

The shell: The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems). The user can customise his/her own shell, and users can use different shells on the same machine. History The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands. You can use any one of these shells if they are available on your system. And you can switch between the different shells once you have found out if they are available.

Bourne shell (sh) C shell (csh) TC shell (tcsh) Korn shell (ksh) Bourne Again SHell (bash)

Sikkim Manipal University

Page No. 8

UNIX

Unit 1

Summary of shell facilities Bourne C TC Korn BASH

command history command alias shell scripts command line editing job control No No Yes No No Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes* Yes Yes Yes Yes Yes Yes

* not the default setting for this shell

1.5 Introduction to few UNIX commands


1.5.1 General format of UNIX commands A UNIX command line consists of the name of a UNIX command (actually the "command" is the name of a built-in shell command, a system utility or an application program) followed by its "arguments" (options and the target filenames and/or expressions). The general syntax for a UNIX command is $ command -options targets Here command can be thought of as a verb, options as an adverb and targets as the direct objects of the verb. In the case that the user wishes to specify several options, these need not always be listed separately (the options can sometimes be listed altogether after a single dash). Note that: Commands are case sensitive. The command ls is different from LS. In fact LS is not recognised as a valid command. Command options normally consist of a single character. e.g. The a option signifies all but use the command:

Sikkim Manipal University

Page No. 9

UNIX

Unit 1

ls a

not

ls -all

Command options can be combined or listed separately. For example: $ ls -al or $ ls -a l The l (letter ell) option signifies long listing

The command item is given last. This is very often a file name. For example: $ ls -l file1.f not $ ls file1.f -l

Sikkim Manipal University

Page No. 10

UNIX

Unit 1

1.5.2 Simple UNIX Commands: The command who gives a list of logged on users: $ who root console Nov 11 08:38 ecl6ql ttyp0 Nov 11 13:01 (129.11.5.140) root ttyp1 Nov 11 08:11 (sun075)

The command finger gives the full name of logged in users: $ finger Login Name root TTY System Idle Administrator When 4:34 Mon 08:38 Where co

1.5.3 Logging into (and out of) UNIX Systems Text-based (TTY) terminals: When an user connects to a UNIX computer remotely (using telnet) or logs in locally using a text-only terminal, the login prompt is displayed: login: At this prompt, user should type in the usename and press the enter/return/ key. The UNIX is case sensitive (i.e. smu, SMU and Smu

are all different logins). The system then prompts the user for the password: login: smu password: The password typed in will not be displayed on the screen.
Sikkim Manipal University Page No. 11

UNIX

Unit 1

If username or password entered is wrong user will get an appropriate message from the computer and will be presented with the login: prompt again. Otherwise user should be presented with a shell prompt which looks like this: $ To log out of a text-based UNIX shell, type "exit" at the shell prompt (or if that doesn't work try "logout"; if that doesn't work press ctrl-d). Graphical terminals: Once you are logged in, user will be presented with a graphical window manager that looks similar to the Microsoft Windows interface. To bring up a window containing a shell prompt look for menus or icons which mention the words "shell", "xterm", "console" or "terminal emulator". To log out of a graphical window manager, look for menu options similar to "Log out" or "Exit". 1.5.4 Changing your password The UNIX command to change the password is passwd: $ passwd The system will prompt user to enter the old password, then for the new password. To eliminate any possible typing errors user has made in the new password, it will ask to reconfirm the new password.

1.6 Summary
UNIX was developed at AT&T Bell labs by ken Thompson and Denis Ritchie with the intention of creating a portable OS. It was finally written in C, and now runs on all machines from palmtops to mainframes. Linux, the free UNIX with contributions from GNU ( who write and distribute free software) is also popular.

Sikkim Manipal University

Page No. 12

UNIX

Unit 1

The distribution of work is shared by kernel which addresses the hardware directly and shell which interprets the user. Each UNIX command does a simple job and allows UNIX to build complex routines by connecting these basic commands. Self Assessment Questions II (SAQ II): 1) ___________allocates time and memory to programs and handles the filestore and communications in response to system calls. 2) ___________ among the following is not a kind of SHELL. a) Bourne shell b) C++ shell c) korn shell. 3) UNIX Commands are case sensitive.(True/False). 4) The command _________ gives a list of logged on users. 5) The command _________ gives the full name of logged in users. 6) The UNIX command to change the password is __________.

1.7 Terminal Questions(TQ)


1) What is an Operating system? 2) Explain the main components of an operating system. 3) Explain the functions of Kernel and Shell of an UNIX OS. 4) Mention the different types of SHELL. 5) Which is the command used to do the following? a. change the password b. List the logged in users c. Get the full name of the logged-in users.

1.8 Answers to SAQs and TQs


SAQ I
Sikkim Manipal University Page No. 13

UNIX

Unit 1

1) Kernel 2) True 3) C 4) True SAQ II 1) Kernel 2) C++ shell 3) True 4) who 5) Finger 6) Passwd TQs 1) section 1.2 2) section 1.2 3) section 1.4 4) section 1.4 5) section 1.5

Sikkim Manipal University

Page No. 14

You might also like