chapter 1 what is unix? by c. shing itec dept radford university

27
Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Upload: shavonne-nelson

Post on 13-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Chapter 1 What is Unix?

By C. Shing

ITEC Dept

Radford University

Page 2: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Objectives

• Understand Unix history

• Describe Unix components

• Understand Unix features

• Introduce vi editor

Page 3: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Pre- History

• 1960 CTSS (MIT Time-sharing system): main frame supports 30 terminals

• 1965: Multics (Bell Lab, MIT, GE) –design 24/7 OS up to 300 terminals, completed in 1975

Page 4: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Brief History

• 1969 (Bell Lab out of Multics project) Ken Thompson design Unics for playing computer game – use DEC PDP-7 assembly language– machine dependent

• 1973 Dennis Ritchie+ Thompson, Bell Lab– more than 90% code in 1970 Ritchie’s C language– machine independent

• 1977 BSD (UC Bekeley Software Distribution – Bill Joy): Sun microsystem based

• 1979 Version 7, Release 4 (SVR4): standard version, , support PC– Used for 2 Unix branches: AT&T System V & UC Berkeley

BSD

Page 5: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Brief History – AT&T System V

• 1980 (AT&T System III ): Implement different memory management algorithms

• 1983 (System V copyright, restrict source code access) : virtual memory, Bourne shell, IPC: message, shared memory, semaphores

• 1984 GNU (Not Unix): (Free Software Foundation-Richard Mathew Stallman):– Free Unix concept: free software– GNU GPL (General Public License-”copyleft”- open source):

freedom to run, copy, distribute, study, change, improve software – More people use, debug, more secure– Free Unix version Software: GNU C, EMACS, GNU C Library, bash

shell (1990)• 1984 X Window (GUI by MIT)• 1986 Minix- mini Unix for PC by Tanenbaum (Harvard)• 1988 XFree86: Free X Window on PC

Page 6: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Brief History – AT&T System V (Cont.)

• Other Unix System V Based Systems:– V.2

• IBM AIX• OSF/1

– V.3– V.4, 1986: Korn shell– V.4.1, 1990

• SUN OS (Solaris), HP/UX

Page 7: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Brief History – Berkeley BSD (Cont.)

• BSD (Berkeley Standard Distribution): – Supports socket networking, C shell, vi– 4.2

• Apollo– 4.3, 1990

• SUN OS (Solaris), HP/UX– 4.4, 1992: NSF Stop funding BSD development

• FreeBSD

Page 8: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Linux Brief History

• 1991 Linux by Linus Torvalds (Finland): reimplementation of minix (small Kernel) for intel 386PC architecture– using Bash shell & GNU C– Unix Like, Multitasking– Free download version 0.02 from FTP catalog Linux– Develop Linux based on POSIX on

http://www.kernel.org

• 1992 POSIX.1(Portable Operating System Interface): IEEE standardize API: system calls (1988) and commands (1992)

Page 9: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Linux Brief History (Cont.)• 1994 Linux 1.0 use X window: penguin bite little Torvalds

– Kernel Version: main.secondary.release-update (e.g 2.6.18-92.e15)• main& secondary version #

– Even #: stable version (e.g. 2.6.xx)– Odd #: under development (e.g. 2.5.xx)

– Distribution (Kernel+Software+Tools+Documentation) #: • rpm installation: CentOS 7.0 (Fedora Linux), RHEL(Red Hat), SuSE• Dbkg installation: Ubuntu, Debian, B2D

– GUI: X server• KDE• GNOME

– Small kernel – good for embedded system: for PDA, Cell Phone, digital camera, home appliance

– Use less power, require less powerful hardware to run, stable- good for server

• 2002 POSIX.2: Standard UNIX Specification (or SUS)

Page 10: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Open Source License

• GPL:GNU, free

• BSD: Berkeley Software Distribution– similar to GPL

• Apache License: any modification must named Apache

Page 11: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Linux Disadvantage

• Non-Profit Organization Developer

• Command Based Control

• Lack of Graphics Support

• Lack of gaming Application

• Lack of Education

Page 12: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Linux Small Home Server Minimum Requirement

• CPU: Pentium III-500

• RAM: 512 MB

• Disk: 20 GB

• VGA RAM (for Console): use X Window - 32 MB

• NIC: 10/100 Mbps

• VGA Card: Nvidia, ATI

Page 13: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Components

• Kernel: in RAM– System calls– Interrupts

• File systems: directory structures (tree)– Directory contains filenames and location of files– Every device is a file

• Process management: share – CPU: time slice 1/10 sec, round-robin– RAM: fixed size page– Disk: fixed size block(1024 Bytes)

Page 14: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Components

• I/O– Character (device)– Block (regular file)– Network (socket)

• IPC (inter-process communication)– Signal: processes in same machine– Pipe: processes in same machine– Socket: processes in different machines– Client/server

Page 15: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Linux File name for Hardware

Hardware device File name

IDE disk /dev/hd[a-d]

SCSI/SATA/USB disk. USB flash /dev/sd[a-p]

Floppy disk /dev/fd[0-1]

Printer 25 pins: /dev/lp[0-2]USB: /dev/usb/lp[0-15]

Mouse USB: /dev/usb/mouse[0-15], /dev/mousePS2: /dev/psaux

CDROM/DVDROM /dev/cdrom

Tape IDE: /dev/ht0SCSI: /dev/st0

Page 16: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Features

• Open system– Internal software source code are available (free or

low cost)

• Platform independent– From PC to supercomputer

• Multi-users: round-robin between users• Multi-tasking: process (execution of a program)

sharing• Virtual memory

– Swap space at least 2 times of RAM

Page 17: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Unix Features

• Simple view of devices-Files (data unit on storage)– Peripheral– Network interface– Disk

• Efficient, robust, simple• Lots of Utilities: tools for users to interact UNIX

– Command line interpreter: process shell command

• System calls similar to library routines– Processes use system-calls to interact with Kernel

• Lots of commercial software• GUI: X Window

Page 18: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 18

vi/vim editor

• vi filename.c (or vim filename.c)

• Document: Please refer to

http://www.chem.brown.edu/instructions/vi.html

Page 19: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 19

Use vi Editor

• 2 modes:– Editor mode (press <esc>): make correction– Insert/open/append mode

(press<i>/<o>/<a>): add text

Page 20: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 20

Use vi Editor (Cont.)

• Editor mode: (Common keys)– <h>:move left, <l>: move right,

<j>: move down, <k>: move up– <0>: beginning of line, <$>: end of line– <w>: next word, <b>: previous word– <:><n>: go to line n

Page 21: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 21

Use vi Editor (Cont.)

• Editor mode: (Cont.)– <x>: delete character, <d><w>: delete word– <d><d>: delete line (to clip board), <Y>: copy

line– <p>: paste from clip board after/below cursor– <P>: paste from clip board before/above cursor– Move cursor to line m,<d><d>, then move cursor to line n, <p>: move line m to below line n– Move cursor to line m,<Y>, then move cursor to line n, <p>: copy line m to below line n

Page 22: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 22

Use vi Editor (Cont.)

• Editor mode: (Cont.)• Note: put a number n before an action will

repeat the action n times.For example:10<j>: move cursor down 10 lines10<x> delete 10 characters10<d><d>: delete 10 lines10<Y>: copy 10 lines

Page 23: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 23

Use vi Editor (Cont.)• Editor mode: (Cont.)

– <r>: replace a character– <c><w> type in word<esc>: replace a word– <R> type in words<esc>: replace/type over words– </>type in word<enter>: search the 1st occurrence of the

word– <:><w>: save, <:><w><q>: save and quit, – <:><w><q>type in filename<enter>: save to filename and

quit– <:><s></><word1></><word2></><enter>: substitute the 1st occurrence of word1 for word2 – <:><1><,><$><s></><word1></><word2></><g><enter>: substitute all the occurrence (globally) of word1 by word2

from line 1 to last line

Page 24: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 24

Use vi Editor (Cont.)

• Editor mode: (Cont.)– <J>: join the cursor line and the line below

into one line– Move cursor to position <i><esc>:

split at the cursor position into 2 lines – <.>: repeat the previous command– <n>: next searched word– <G>: go to last line– <ctrl><g>: file status

Page 25: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 25

Use vi Editor (Cont.)

• Insert/open/append mode: (Common keys)– <i>type in words<esc>:insert words before the

cursor– <a>type in words<esc>:append words after the

cursor– <o>type in words<esc>:open lines after the cursor

and append words – <O>type in words<esc>:open lines before the

cursor

and append words

Page 26: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Slide 26

Class Example• Hands On Example0:

edit the following 2 lines in file .exrc (vi ~/.exrc) :abbr #b /************************ :abbr #e ************************/

Then when you usevi template.c

And after press<i>/<a>/<o> to insert text, you type#b followed by <Enter>, you add a line /******** in.

Similarly, when you type #e followed by <Enter>, you add a line ********/ in

• Example 1

Page 27: Chapter 1 What is Unix? By C. Shing ITEC Dept Radford University

Reference

• Unix History: Chapter 16

• Unix internal: Chapter 14

• Linux How-to Documentation: www.tldp.org

• Linux: www.study-area.org