For example, an OS ensures safeaccessto a printer by allowing only one application program to send data directlyto the printer at any one time. An OS encouragesefficientuseof the CPU by suspending programs that are waiting for I/O operations tocomplete to make way for programs that can use the CPU more productively.An OS also provides convenientabstractions(suchas files rather than disk locations) which isolate application programmersand users from the details of the underlying hardware.
Fig. 1.1: General operating system architectureFig. 1.1 presents the architecture of a typical operatingsystem and shows how an OS succeeds in presenting users and applicationprograms with a uniform interface without regard to the details of theunderlying hardware. We see that:
- The operating system kernelis in direct control of the underlying hardware. The kernel provides low-leveldevice, memory and processor management functions (e.g. dealing with interruptsfrom hardware devices, sharing the processor among multiple programs, allocatingmemory for programs etc.)
- Basic hardware-independent kernel services are exposed tohigher-level programs through a library of systemcalls (e.g. services to create a file,begin execution of a program, or open a logical network connection to anothercomputer).
- Application programs(e.g. word processors, spreadsheets) and systemutility programs (simple but useful applicationprograms that come with the operating system, e.g. programs which findtext inside a group of files) make use of system calls. Applications andsystem utilities are launched using a shell(a textual command line interface) or a graphicaluser interface that provides direct userinteraction.
Operating systems (and different flavours of the same operatingsystem) can be distinguished from one another by the system calls, systemutilities and user interface they provide, as well as by the resource schedulingpolicies implemented by the kernel.
1.3A Brief History of UNIXUNIX has been a popular OS for more than twodecades because of its multi-user, multi-tasking environment, stability,portability and powerful networking capabilities. What follows here isa simplified history of how UNIX has developed (to get an idea for howcomplicated things really are, see the web site ).
Fig. 1.2: Simplified UNIX FamilyTreeIn the late 1960s, researchers from General Electric,MIT and Bell Labs launched a joint project to develop an ambitious multi-user,multi-tasking OS for mainframe computers known as MULTICS (MultiplexedInformation and Computing System). MULTICS failed (for some MULTICS enthusiasts "failed" is perhaps toostrong a word to use here), but it did inspire KenThompson, who was a researcher at Bell Labs, to have a go at writing asimpler operating system himself. He wrote a simpler version of MULTICSon a PDP7 in assembler and called his attempt UNICS (Uniplexed Informationand Computing System). Because memory and CPU power were at a premium inthose days, UNICS (eventually shortened to UNIX) used short commands tominimize the space needed to store them and the time needed to decode them- hence the tradition of short UNIX commands we use today, e.g. ls,cp, rm, mv etc.Ken Thompson then teamed up with Dennis Ritchie, the authorof the first C compiler in 1973. They rewrote the UNIX kernel in C - thiswas a big step forwards in terms of the system's portability - and releasedthe Fifth Edition of UNIX to universities in 1974. The Seventh Edition,released in 1978, marked a split in UNIX development into two main branches:SYSV (System 5) and BSD (Berkeley Software Distribution). BSD arose fromthe University of California at Berkeley where Ken Thompson spent a sabbaticalyear. Its development was continued by students at Berkeley and other researchinstitutions. SYSV was developed by AT&T and other commercial companies.UNIX flavours based on SYSV have traditionally been more conservative,but better supported than BSD-based flavours.The latest incarnations of SYSV (SVR4 or System 5 Release4) and BSD Unix are actually very similar. Some minor differences are tobe found in file system structure, system utility names and optionsand system call libraries as shown in Fig 1.3.
Feature Typical SYSV Typical BSD kernel name /unix /vmunix
boot init /etc/rc.d directories /etc/rc.* files
mounted FS /etc/mnttab /etc/mtab
default shell sh, ksh csh, tcsh
FS block size 512 bytes->2K 4K->8K
print subsystem lp, lpstat, cancel lpr, lpq, lprm
echo command echo "\c" echo -n
(no new line)
ps command ps-fae ps -aux
multiple wait poll select
syscalls
memory access memset, memcpy bzero, bcopy
syscalls
Fig. 1.3: Differences between SYSV and BSDLinux is a free open source UNIX OS for PCs that was originallydeveloped in 1991 by Linus Torvalds, a Finnish undergraduate student. Linuxis neither pure SYSV or pure BSD. Instead, incorporates some features fromeach (e.g. SYSV-style startup files but BSD-style file system layout) andaims to conform with a set of IEEE standards called POSIX (Portable OperatingSystem Interface). To maximise code portability, it typically supportsSYSV, 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 sourcecode for the Linux kernel is freely available so that anyone can add featuresand correct deficiencies. This approach has been very successful and whatstarted as one person's project has now turned into a collaboration ofhundreds of volunteer developers from around the globe. The open sourceapproach has not just successfully been applied to kernel code, but alsoto application programs for Linux (see e.g. ).As Linux has become more popular, several different developmentstreams or distributions have emerged, e.g. Redhat, Slackware, Mandrake,Debian, and Caldera. A distribution comprises a prepackaged kernel, systemutilities, GUI interfaces and application programs.Redhat is the most popular distribution because it hasbeen 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 comprehensiveset of utilities and applications including the X Windows graphics system,GNOME and KDE GUI environments, and the StarOffice suite (an open sourceMS-Office clone for Linux).
1.4Architecture of the Linux Operating SystemLinux has all of the components of a typicalOS (at this point you might like to refer back to Fig 1.1):
- Kernel
The Linux kernel includes device driver support for alarge number of PC hardware devices (graphics cards, network cards, harddisks etc.), advanced processor and memory management features, and supportfor many different types of filesystems (including DOS floppies and theISO9660 standard for CDROMs). In terms of the services that it providesto application programs and system utilities, the kernel implements mostBSD and SYSV system calls, as well as the system calls described in thePOSIX.1 specification.The kernel (in raw binary form that is loaded directlyinto memory at system startup time) is typically found in the file /boot/vmlinuz,while the source files can usually be found in /usr/src/linux.The latestversion of the Linux kernel sources can be downloaded from
- Shells and GUIs
Linux supports two forms of command input: through textualcommand line shells similar to those found on most UNIX systems (e.g. sh- the Bourne shell, bash - the Bourne again shell and csh - the C shell)and through graphical interfaces (GUIs) such as the KDE and GNOME windowmanagers. If you are connecting remotely to a server your access will typicallybe through a command line shell.
- System Utilities
Virtually every system utility that you would expectto find on standard implementations of UNIX (including every system utilitydescribed in the POSIX.2 specification) has been ported to Linux. Thisincludes commands such as ls, cp, grep, awk, sed, bc, wc, more,and so on. These system utilities are designed to be powerful tools thatdo a single task extremely well (e.g. grep finds text inside fileswhile wc counts the number of words, lines and bytes inside afile). Users can often solve problems by interconnecting these tools insteadof writing a large monolithic application program.Like other UNIX flavours, Linux's system utilities alsoinclude server programs called daemonswhich provide remote network and administration services (e.g. telnetdand sshd provide remote login facilities, lpd providesprinting services,httpd serves web pages, crond runsregular system administration tasks automatically). A daemon (probablyderived from the Latin word which refers to a beneficient spirit who watchesover someone, or perhaps short for "Disk And Execution MONitor") is usuallyspawned automatically at system startup and spends most of its time lyingdormant (lurking?) waiting for some event to occur.
- Application programs
Linux distributions typically come with several usefulapplication programs as standard. Examples include the emacs editor,xv(an image viewer), gcc (a C compiler), g++ (a C++ compiler),xfig(a drawing package), latex (a powerful typesetting language) andsoffice(StarOffice, which is an MS-Office style clone that can read and writeWord, Excel and PowerPoint files).Redhat Linux also comes with rpm, the RedhatPackage Manager which makes it easy to install and uninstall applicationprograms.
1.5Logging into (and out of) UNIX SystemsText-based (TTY) terminals:When you connect to a UNIX computer remotely (using telnet)or when you log in locally using a text-only terminal, you will see theprompt: login:At this prompt, type in your usename and press the enter/return/key. Remember that UNIX is case sensitive (i.e. Will, WILL and will areall different logins). You should then be prompted for your password: login: will
password:Type your password in at the prompt and press the enter/return/key. Note that your password will not be displayed on the screen as youtype it in.If you mistype your username or password you will getan appropriate message from the computer and you will be presented withthe login: prompt again. Otherwise you should be presented witha shell prompt which looks something like this: $To log out of a text-based UNIX shell, type "exit" atthe shell prompt (or if that doesn't work try "logout"; if that doesn'twork press ctrl-d).
Graphical terminals:If you're logging into a UNIX computer locally, or ifyou are using a remote login facility that supports graphics, you mightinstead be presented with a graphical prompt with login and password fields.Enter your user name and password in the same way as above (N.B. you mayneed to press the TAB key to move between fields).Once you are logged in, you should be presented with agraphical window manager that looks similar to the Microsoft Windows interface.To bring up a window containing a shell prompt look for menus or iconswhich mention the words "shell", "xterm", "console" or "terminal emulator".To log out of a graphical window manager, look for menuoptions similar to "Log out" or "Exit".
1.6Changing your passwordOne of the things you should do when you login for the first time is to change your password.The UNIX command to change your password is passwd: $ passwdThe system will prompt you for your old password, thenfor your new password. To eliminate any possible typing errors you havemade in your new password, it will ask you to reconfirm your new password.Remember the following points when choosing your password:
- Avoid characters which might not appear on all keyboards,e.g. ''.
- The weakest link in most computer security is user passwordsso keep your password a secret, don't write it down and don't tell it toanyone else. Also avoid dictionary words or words related to your personaldetails (e.g. your boyfriend or girlfriend's name or your login).
- Make it at least 7 or 8 characters long and try to use amix of letters, numbers and punctuation.
1.7General format of UNIX commandsA UNIX command line consists of the name of aUNIX 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 syntaxfor a UNIX command is $ command -options targetsHere command can be though of as a verb, optionsasan adverb and targets as the direct objects of the verb. In thecase that the user wishes to specify several options, these need not alwaysbe listed separately (the options can sometimes be listed altogether aftera single dash).(BACK TO COURSE CONTENTS) 93ddb68554