Transcript UNIX

Chapter 1
Introduction
©Brooks/Cole,
2001
The history of UNIX
UNICS
1969년
UNIX V6
1BSD
UNIX V7
XENIX
3BSD
UNIX
System III
UNIX
System V
HP-UX 1.0
Linux
AIX 1.0
UNIX
System V
Release 4
4BSD
SunOS 1.0
Solaris 1
Solaris 2
AIX 3.1
HP-UX 10.0
OpenServer 5 HP-UX 11i
AIX 5.1L
Unixware 7.1
Solaris 9 FreeBSD 4.7
©Brooks/Cole,
2001
Unix Yesterday
• 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.
©Brooks/Cole,
2001
Unix Yesterday
•
A few years later, a colleague of Ken’s, 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:이식성↑)
•
Dennis Ritchie
AT&T, Bell Labs’ parent company, was not
allowed to enter computer business, so Unix was
not commercialized originally.
©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.
©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
©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.
©Brooks/Cole,
2001
http://en.wikipedia.org/wiki/Unix
Unix vs. Linux
©Brooks/Cole,
2001
Sun Ray 실습실 구성도
SunFire V880
(ORACLE DB Server)
Switching Hub
Private Network
ce: Sun Ultra1
(Web Server)
Sun Ultra1
(Mail Server: 교수)
Sun Ultra1
(Mail Server: 학생)
Sunfire V880 Spec.
•2 x 750MHz UltraSPARC-III,
•4GB Memory, 6 x 36.4GB FCAL Disks
Sun Ray-1 50EA
• • • • •
©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.
©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.
©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.
©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
©Brooks/Cole,
2001
Figure 1-1
1.2 Computer System
©Brooks/Cole,
2001
Figure 1-2
Components of Computer Hardware
©Brooks/Cole,
2001
Figure 1-3
Types of Software
©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
©Brooks/Cole,
2001
Figure 1-4
The Time-Sharing Environment
©Brooks/Cole,
2001
Figure 1-5
The Client/Server Environment
©Brooks/Cole,
2001
Figure 1-6
Components of UNIX
©Brooks/Cole,
2001
c programs
scripts
user
shell and utilities
ls
ksh
gcc
find
open()
fork()
exec()
kernel
hardware
©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
©Brooks/Cole,
2001
The kernel(커널)
• The core of the SunOS operating system
• Initializes the systems
• Manages devices, memory, swap space,
processes, daemons, file systems
• Controls the functions between the system
programs and the system hardware
• Provides programmatic interfaces (APIs)
©Brooks/Cole,
2001
The shell(Windows XP)
©Brooks/Cole,
2001
©Brooks/Cole,
2001
The shell(CDE)
©Brooks/Cole,
2001
The shell(CDE)
©Brooks/Cole,
2001
The shell(단말기)
©Brooks/Cole,
2001
The shell
• An interpreter or translator of commands
• An interactive interface between the user and
other user programs
• The 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
©Brooks/Cole,
2001
Figure 1-7
Some Standard UNIX Shells
©Brooks/Cole,
2001
The shell
• Bourne shell ($)
– The default shell
• C shell (%)
– Similar syntax to the C programming language
– Aliasing, history, command-line editing, jobcontrol
• Korn shell ($)
– A superset of the Bourne shell
– Aliasing, history, command-line editing
©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
©Brooks/Cole,
2001
1.5 Accessing UNIX
• User ID
• Passwords
• Interactive Session
- login
- interaction
- logout
©Brooks/Cole,
2001
Figure 1-8
Interactive Session
©Brooks/Cole,
2001
Figure 1-9
1.6 Commands
Command Source and Destination
©Brooks/Cole,
2001
Figure 1-10
General Command Format
©Brooks/Cole,
2001
Figure 1-11
1.7 Common Commands
The date Command
-u // GMT
Greenwich Mean Time
©Brooks/Cole,
2001
Figure 1-12
The calendar Command
$ cal 8 2010
$ cal 2010
©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
-----------------------------------------------------------©Brooks/Cole,
2001
Figure 1-13
The who Command
©Brooks/Cole,
2001
Session 1.3. Basic who Command
Login time
$ 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
Process id
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
------------------------------------------------------------
Idle time
H:M, old : 24시간
©Brooks/Cole,
. : doing in last minute2001
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
-----------------------------------------------------------©Brooks/Cole,
2001
Figure 1-14
The passwd Command
©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.
-----------------------------------------------------------©Brooks/Cole,
2001
Figure 1-15
The echo Command
©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
------------------------------------------------------
©Brooks/Cole,
2001
Figure 1-16
The man Command
©Brooks/Cole,
2001
Session 1.10 man Documentation
$ man cal
cal(1)
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.
------------------------------------------------------------
©Brooks/Cole,
2001
Figure 1-17
The lpr Command
©Brooks/Cole,
2001
Figure 1-18
The tty Command
©Brooks/Cole,
2001
Figure 1-19
The clear Command
©Brooks/Cole,
2001
Figure 1-20
The stty Command
©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
-------------------------------------------------------©Brooks/Cole,
2001
Figure 1-21
The script Command
©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
------------------------------------------------------------
©Brooks/Cole,
2001
Figure 1-22
The uname Command: system name
©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
------------------------------------------------------------
©Brooks/Cole,
2001
Figure 1-23
The bc Command
©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
-----------------------------------------------------------©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
©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
------------------------------------------------------------
©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
©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.
©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.
©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).
©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.
©Brooks/Cole,
2001