©brooks/cole, 2001 chapter 1 introduction. ©brooks/cole, 2001 the history of unix linux 1969 년

Download ©Brooks/Cole, 2001 Chapter 1 Introduction. ©Brooks/Cole, 2001 The history of UNIX Linux 1969 년

If you can't read please download the document

Upload: alberta-price

Post on 13-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

  • Slide 1

Brooks/Cole, 2001 Chapter 1 Introduction Slide 2 Brooks/Cole, 2001 The history of UNIX Linux 1969 Slide 3 Brooks/Cole, 2001 A computer scientist named Ken Thompson at Bell Laboratories built the first version of UNIX. It was built to support some gaming needs that could not be met by existing systems. written by using assembly language, only a single-user system, no network capability, poor memory-management system for sharing memory between processes. In spite of the shortcomings, --> efficient, compact, and fast, which was exactly what he wanted. Unix Yesterday Slide 4 Brooks/Cole, 2001 Unix Yesterday A few years later, a colleague of Kens, Dennis Ritchie, suggested that they rewrite UNIX using the C language. the UNIX system suddenly had a huge advantage over other operating systems - its source code was understandable. Only a small percentage of the original source code remained in assembly language, which meant the porting the operating system to a different machine was quite easy. (Portability: ) AT&T, Bell Labs parent company, was not allowed to enter computer business, so Unix was not commercialized originally. Dennis Ritchie Slide 5 Brooks/Cole, 2001 Unix Yesterday Bell Laboratories allowed universities to obtain a free copy of the UNIX source code. The University of California at Berkeley, made some huge improvements over the years, including the first good memory-management system and the first real networking capability. UC Berkeley offered a version of UNIX, called BSD (Berkeley Standard Distribution) to the general public. Slide 6 Brooks/Cole, 2001 Unix Today The currently commercially available versions of UNIX include, but are not limited to, offerings from AT&T, DEC, IBM, HP, Silicon Graphics, Inc., and Sun Microsystems. A more recent entry into the UNIX world is Linux, a free version of UNIX written by a student in Finland and now marketed and supported by several different companies. (1991) Embedded versions of UNIX are available for various hardware platforms. Android Slide 7 Brooks/Cole, 2001 Unix Tomorrow UNIX will need to embrace some of the newer trends in computing, such as distributed and parallel processing and object-oriented programming. Linux is a big player in the backend and on the desktop. Open Source community contributes great enhancements to the operating system, utilities and applications. Slide 8 Brooks/Cole, 2001 Unix vs. Linux http://en.wikipedia.org/wiki/Unix Slide 9 Brooks/Cole, 2001 Sun Ray SunFire V880 (ORACLE DB Server) Sun Ray-1 50EA ce: Sun Ultra1 (Web Server) Sun Ultra1 (Mail Server: ) Sun Ultra1 (Mail Server: ) Switching Hub Private Network Sunfire V880 Spec. 2 x 750MHz UltraSPARC-III, 4GB Memory, 6 x 36.4GB FC- AL Disks Slide 10 Brooks/Cole, 2001 Chapter 1. Introductiom Welcome to UNIX, the open operating system. UNIX is found on virtually all computer hardware in use today. In fact, its very pervasiveness is most likely the reason you are starting to explore its capabilities. In this text, we introduce you to the basic aspect of UNIX as it is found in most modern installations. Slide 11 Brooks/Cole, 2001 To the casual user, UNIX is simple and easy to use. To the experienced user, it is powerful with a certain elegance that makes it extremely popular. We start with the simple aspects, showing you the ease and simplicity of the system, and then gradually increase your knowledge and understanding until you are a UNIX power user. This chapter introduces you to the UNIX environment. After providing a basic understanding of its environment, we show you how to access a UNIX system and present its basic structure and some common commands. Slide 12 Brooks/Cole, 2001 1.1 Why Unix? Several features of UNIX have made it very popular. Its popularity is still growing, partially due to the development of Linux version that has been ported to many platforms. In this section, we describe some of the features that have made UNIX so popular. Slide 13 Brooks/Cole, 2001 1.1 Why Unix? Portable UNIX is found on more hardware platforms than any other operating system ever developed. Its widespread use can be directly traced to the decision to develop it using the C language. Because C programs are easily moved from one H/W environment to another, it is relatively simple to port it to different environments. All that is needed is a standard C compiler. Multi-user Multi-tasking Networking Organized File System Device Independence Utilities Services Slide 14 Brooks/Cole, 2001 Figure 1-1 1.2 Computer System Slide 15 Brooks/Cole, 2001 Figure 1-2 Components of Computer Hardware Slide 16 Brooks/Cole, 2001 Figure 1-3 Types of Software Slide 17 Brooks/Cole, 2001 Operating Systems A computer system cannot function without an operating system. There are many different operating systems that are available for PCs, minicomputers, and mainframes; the most common ones are Windows, VMS, MacOS, and UNIX. MS Windows is only available for PCs VMS is only available for mini-computers and mainframes, and UNIX is available for virtually all platforms. programs operating system hardware Slide 18 Brooks/Cole, 2001 Figure 1-4 The Time-Sharing Environment Slide 19 Brooks/Cole, 2001 Figure 1-5 The Client/Server Environment Slide 20 Brooks/Cole, 2001 Figure 1-6 Components of UNIX Slide 21 Brooks/Cole, 2001 user shell and utilities kernel hardware c programs scripts ls ksh gcc find open() fork() exec() Slide 22 Brooks/Cole, 2001 Kernel - process control - resource management Shell : interactive interface (user, program), visible to the user (fig. 1.7) - interpreter - programming capability Utilities : Standard UNIX comes complete with at least 200 small utility programs, usually including: shells, editors, a C compiler, matching with regular expressions, searching, a sorting utility, software development tools, text-processing tools, etc. Applications Slide 23 Brooks/Cole, 2001 The kernel( ) coreThe core of the SunOS operating system InitializesInitializes the systems ManagesManages devices, memory, swap space, processes, daemons, file systems ControlsControls the functions between the system programs and the system hardware Provides programmatic interfaces (APIs) Slide 24 Brooks/Cole, 2001 The shell(Windows XP) Slide 25 Brooks/Cole, 2001 Slide 26 The shell(CDE) Slide 27 Brooks/Cole, 2001 The shell(CDE) Slide 28 Brooks/Cole, 2001 The shell( ) Slide 29 Brooks/Cole, 2001 The shell An interpreter or translator of commandsAn interpreter or translator of commands An interactive interface between the user and other user programs accepts commands interprets these commands executes themThe shell accepts commands you enter, it interprets these commands, and then it executes them A method by which the user can interact with the resources of the computer system Slide 30 Brooks/Cole, 2001 Figure 1-7 Some Standard UNIX Shells Slide 31 Brooks/Cole, 2001 The shell Bourne shell ($) The default shell C shell (%) Similar syntax to the C programming language Aliasing, history, command-line editing, job- control Korn shell ($) A superset of the Bourne shell Aliasing, history, command-line editing Slide 32 Brooks/Cole, 2001 BASH ($) The GNU Bourne-Again shell A Bourne-compatible shell that incorporates useful features from the Korn and C shells Z shell ($) Resemble the Korn shell with many enhancements TC shell (%) A completely compatible version of the C shell with additional enhancements Slide 33 Brooks/Cole, 2001 1.5 Accessing UNIX User ID Passwords Interactive Session - login - interaction - logout Slide 34 Brooks/Cole, 2001 Figure 1-8 Interactive Session Slide 35 Brooks/Cole, 2001 Figure 1-9 1.6 Commands Command Source and Destination Slide 36 Brooks/Cole, 2001 Figure 1-10 General Command Format Slide 37 Brooks/Cole, 2001 Figure 1-11 1.7 Common Commands The date Command -u // GMT Greenwich Mean Time Slide 38 Brooks/Cole, 2001 Figure 1-12 The calendar Command $ cal 8 2010 $ cal 2010 Slide 39 Brooks/Cole, 2001 Session 1.2. Calendar Output $ cal 1 2001 January 2001 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ------------------------------------------------------------ Slide 40 Brooks/Cole, 2001 Figure 1-13 The who Command Slide 41 Brooks/Cole, 2001 Session 1.3. Basic who Command $ who nb045527 ttyq0 Mar 15 15:23 tran ttyq1 Mar 10 12:15 gilberg ttyq5 Mar 15 14:57 ryan ttyq12 Mar 15 11:57 rdr59404 ttyq21 Mar 15 15:03 ------------------------------------------------------------ Session 1.4. The who Command Option u $ who u// idle time nb045527 ttyq0 Mar 15 15:23 0:41 19590 tran ttyq1 Mar 10 12:15 old 8315 gilberg ttyq5 Mar 15 14:57. 17737 ryan ttyq12 Mar 15 11:57 0:01 2378 rdr59404 ttyq21 Mar 15 15:03. 18082 ------------------------------------------------------------ Process id Login time Idle time H:M, old : 24 . : doing in last minute Slide 42 Brooks/Cole, 2001 Session 1.5. The who Command Option H $ who -uH NAME LINE TIME IDLE PID COMMENTS nb045527 ttyq0 Mar 15 15:23 0:41 19590 tran ttyq1 Mar 10 12:15 old 8315 gilberg ttyq5 Mar 15 14:57. 17737 ryan ttyq12 Mar 15 11:57 0:01 2378 rdr59404 ttyq21 Mar 15 15:03. 18082 ------------------------------------------------------------ Session 1.6 who with Argument am i $ who am i// $ whoami id gilberg ttyq3 Mar 15 16:34 ------------------------------------------------------------ Slide 43 Brooks/Cole, 2001 Figure 1-14 The passwd Command Slide 44 Brooks/Cole, 2001 Session 1.7. passwd Command $ passwd Changing password for... Old password: New password: Re-enter new password: ------------------------------------------------------------ Session 1.8. passwd Change Error They don't match Try again. ------------------------------------------------------------ Slide 45 Brooks/Cole, 2001 Figure 1-15 The echo Command Slide 46 Brooks/Cole, 2001 Session 1.9 The echo Command $ echo Hello World Hello World $ echo "Error 105: Invalid total sales" Error 105: Invalid total sales ------------------------------------------------------ Slide 47 Brooks/Cole, 2001 Figure 1-16 The man Command Slide 48 Brooks/Cole, 2001 Session 1.10 man Documentation $ man cal cal(1) NAME cal - print calendar SYNOPSIS cal [ [ month ] year ] DESCRIPTION cal prints a calendar for the specified year. If a month is also specified, a calendar just for that month is printed. If neither is specified, a calendar for the present month is printed. The month is a number between 1 and 12. The year can be between 1 and 9999. The calendar produced is that for England and the United States. NOTES An unusual calendar is printed for September 1752. That is the month 11 days were skipped to make up for lack of leap year adjustments. To see this calendar, type: cal 9 1752 The command cal 83 refers to the year 83, not 1983. The year is always considered to start in January even though this is historically naive. ------------------------------------------------------------ Slide 49 Brooks/Cole, 2001 Figure 1-17 The lpr Command Slide 50 Brooks/Cole, 2001 Figure 1-18 The tty Command Slide 51 Brooks/Cole, 2001 Figure 1-19 The clear Command Slide 52 Brooks/Cole, 2001 Figure 1-20 The stty Command Slide 53 Brooks/Cole, 2001 Session 1.11. The stty Command $ stty speed 9600 baud; -parity hupcl clocal line = 1; intr = ^A; erase = DEL; old-swtch = ^@; dsusp = ^@; brkint -inpck icrnl onlcr tab3 echo echoe echok echoke -------------------------------------------------------- Slide 54 Brooks/Cole, 2001 Figure 1-21 The script Command Slide 55 Brooks/Cole, 2001 Session 1.12. Session Log Example $ script// $ script myfilescript Script started, file is typescript $ date Mon May 28 13:40:59 PDT 2001 $ who forouzan ttyq0 May 28 12:33 (153.18.171.128) spk49772 ttyq3 May 28 11:27 (c296129-a.frmt1.sfba.home.com) xf043637 ttyq4 May 28 11:25 (ACB46F15.ipt.aol.com) $ ls -l total 168 -rw-r--r-- 1 forouzan staff 26 Apr 22 10:45 file1.dat -rw-r--r-- 1 forouzan staff 49 May 14 15:42 notes.dat $ exit Script done, file is typescript ------------------------------------------------------------ Slide 56 Brooks/Cole, 2001 Figure 1-22 The uname Command: system name Slide 57 Brooks/Cole, 2001 Session 1.13 Demonstrate uname Options $ uname IRIX64 $ uname s// os IRIX64 $ uname -r // release 6.5 $ uname -n // name only challenger $ uname -sr IRIX64 6.5 $ uname -a IRIX64 challenger 6.5 04191225 IP19 ------------------------------------------------------------ Slide 58 Brooks/Cole, 2001 Figure 1-23 The bc Command Slide 59 Brooks/Cole, 2001 Session 1.14. Calculator ( bc ) Arithmetic Operations $ bc 12 + 8 20 45 - 56 -11 34 + 34 * 3 136 34 + 34 / 3 45 8%3 2 24.5 ^ 67 53595273643724563625813104911439902299022950.4 ------------------------------------------------------------ Slide 60 Brooks/Cole, 2001 Session 1.15 Demonstrate Scale Expression 19/3 6 scale=2// 2 : 19/3 6.33 20/3 6.66 21/3 7.00 scale=8 19/3 6.33333333 20/3 6.66666666 21/3 7.00000000 scale=0 19/3 6 Slide 61 Brooks/Cole, 2001 Session 1.16 Demonstrate Calculator Input Base $ bc ibase=2 111 7 111*111 49 ibase=8 10 8 10*11 72 ibase = 16 1A 26 10 * 10 256 ------------------------------------------------------------ Slide 62 Brooks/Cole, 2001 Session 1.17 Demonstrate Calculator Output Base obase=2 5 101 15 / 3 101 obase=8 9 11 99 / 10 11 obase = 13 13 10 130 / 10 10 obase = 16 26 1A 256 100 16 * 16 100 Slide 63 Brooks/Cole, 2001 & 1.13 Practice Set Review Questions ( ) 1. ? ( ; portability) Portable refers to the ability of the operating system to be moved to new platforms without the need for a major rewrite. Portable operating systems are typically implemented in a high level language such as C, which is available on many platforms. Slide 64 Brooks/Cole, 2001 2. A "multiuser operating system" allows multiple users to share the hardware and software resources at the same time. A "multitasking operating systems" allows more than one task to run at the same time. Slide 65 Brooks/Cole, 2001 6. A shell provides an interface for a user to read commands, and execute them. Additionally, it is a scripting language that allows users to write shell programs (scripts). Slide 66 Brooks/Cole, 2001 Exercises 23. cal: a. No error. b. Invalid option. c. cat should be cal d. Invalid syntax. 24. date: a. Invalid case --- should be date, not Date. b. Invalid option. c. Invalid argument. d. Missing + prefix.