/* You are not expected to understand this */ if (rp -> p_flag & SSWAP) { rp -> p_flag =& ~SSWAP; aretu (u.u_ssav); }
lines 2238-2243; Sixth Edition Western Electric Company
Unix History
q
In early 60s, computers were expensive, had minimal memory and were single user
u
All activities were designed to make things easy for the computer
In the mid 60s, MIT, Bell Labs, and General Electric teamed to build an OS for a large computer, the GE-645 that would accommodate 1,000 simultaneous users q Multics (Multiplexed Information and Computing Service) q In March 69, Bell pulled out of the project
q
u
Ken Thompson had been using Multics to run Space Travel but it cost $70 a run Thompson found a cast-off PDP-7 with the intent to write a file system This file system became the roots of Unix Unix was originally called UNICS, a pun on Multics (Uniplexed Information and Computing Service) Unix struggled along on an obsolete, underpowered machine until the PDP-11 was released
Space Travel
q q
Tree-structured file system Separate, identifiable program to do command interpretation (the shell) Structure files with no structure except as a sequence of bytes, in most cases with no interpretation by the OS Text files as simple sequences of characters separated by new-lines Semantics of I/O operations (read and write) as referring to a file handle, buffer, and a count, thus concealing the underlying structure of the device
5
Unix Philosophy
Write programs that do one thing and do it well q Write programs that work together, allowing the output of one to become the input of another
q
u
Write programs that handle text streams, because that is a universal interface
The Law
January, 1949 DOJ filed an antitrust complaint against Western Electric and AT&T q In January, 1956, a consent decree was entered
q
u
u u
AT&T and Western Electric were enjoined from commencing ... manufacture for sale or lease any equipment [other than that used in providing telephone or telegraph services], from engaging ... in any business not of a character or type engaged in by Western Electric or its subsidiaries AT&T was enjoined from engaging in any business other than the furnishing of common carrier communications services
10
Suddenly requests started flowing in for Unix licenses Computers werent phones and telegrams thus putting them in danger of antagonizing the Justice Department
11
no advertising no support
no bug fixes
payment in advance
12
q
q
May 1974 - nearly a dozen Spring 75 - three dozen June 75 - plus 20 new installations October 75 - 60 installations March 76 - 80 installations September 76 - 138 installations
Canada 13 Great Britain 10 Australia 4 Israel 3 The Netherlands 3 Austria Belgium Germany Venezuela United States 1 1 1 1 101
13
Berkeley Unix
Robert Fabrey, of UC Berkeley, was on the SOSP program when Thompson presented his paper q Together with the Math department, he purchased a PDP-11/45 and had Unix running by Jan 74 q By 78 Bill Joy had produced a Pascal compiler and began producing the Berkeley Software Distribution (BSD) for $50 containing:
q
14
Something was created at BTL and distributed in source code form A user in the UK created something from it A user in California improved on both the original and the UK version It was distributed to the user community at cost The improved version was incorporated into the next BTL release There was no way BTL Patent and Licensing could control this!
15
16
Dueling Unixes
Up until 78, Unix meant AT&Ts operating system q After this, there were two principle flavors of Unix
q
u u
BSD System V
Commercially, both were a success but were not totally compatible with each other q This led to the formation of the Open Software Foundation and the competing Unix International
q
17
AT&T System V Interactive q Masscomp q Microport q Microsoft q Motorola q NCR q SCO q Silicon Graphics q Tandy q Sun (Solaris)
q
18
Apollo q AT&T q DEC q Altos q Eakins q Apollo q Gould q Compaq q Integrated Solutions q Convergent q Masscomp q HP q mt Xinu q Honeywell q NSC q IBM q Wollongong q ITT q Sun (SunOS) q Intel q Sperry
CISC 1480/KRF Copyright 1999 by Kenneth R. Frazer
Portability
u u
Written in C, only a small portion is in assembly Runs on micros, minis, main frames, and super computers
q
q
q
q
Ran on (relatively) inexpensive hardware Designed to be adaptable to changing user environments It was inexpensive Source was available Permits access to its operating features
u
Challenges of Unix
q q
Most commands are short, terse, and nondescriptive q Relatively unforgiving of user mistakes
20
21
22
23
Major Personalities
Ken Thompson q Co-Inventor of Unix q Dennis Ritchie q Co-Inventor of Unix q Joe Ossanna q Author of troff q Rudd Canaday q Original file system collaborator q Robert Fabrey q Obtained DARPA funding for BSD q Steve Johnson q Author of lint and yacc q Stephen Bourne q Author of the Bourne shell, sh q Doug McIlroy q Originator of pipe concept q Kirk McKusick q Wrote Berkeley Fast File System q Armando Stettner q Got DEC to acknowledge Unix q Heinz Lycklama q Chaired first Unix standards group q Bill Joy q Author of csh, ex, vi, termcap, and much of BSD 24
q
25
26
the hardware the kernel, the hardware interface unique to a platform the shell and other system utilities the application programs
27
28
So Why Unix?
q
Multi-tasking/multi-processing means more than one command, program, process can seemingly be in simultaneous execution
Hardware specific kernel means that a small core piece of functionality is coded specifically for the platform
u
29
Unix Shells
A shell is the user interface or set of programs user to interact with Unix and process commands q Common shells are:
q
u u u
Bourne C Korn inherits environmental variables set by the previous shell stops the previous shell becomes the current shell
30
Approximately 20 times faster than C shell because it is simpler and doesnt carry as much baggage
31
C Shell (csh)
Written by Bill Joy at University of California at Berkeley q Slower and more complex than Bourne shell, but has facilities to make it more user friendly
q
u u u u
32
33
Superuser
q q
Allowed access to all files q Allowed to run all commands q System administrator has superuser privileges q Can be very dangerous, all the Unix built in protections are by-passed
34
Password Security
Unfortunately, password security is a necessity q Good passwords have several characteristics
q
u u u u
Minimum of six (6) characters Mixture of alpha and numeric characters Mixture of upper and lower case No real words l Susceptible to a dictionary attack
35
To change your password l clyde% passwd l Changing password for ??? on clyde. l Old password: your_current_password l New password: your_new_password l Retype new password: your_new_password l clyde%
To logout
clyde% exit u or clyde% logout
u
36
SunOS UNIX (yof) login: username Password: your_password Last Login: Sat Aug 7 10:15:50 on ttyp0 SunOS Release 4.1.3_U1 (GENERIC) .......... yof%
37
Then the shell specified in /etc/passwd is executed and user is placed in his HOME directory
u
.login is executed only at login .cshrc is executed every time a new shell is spawned
38
.cshrc
set path = (. ~ $lpath ~/bin /usr/local /usr/ucb /usr/bin /usr/etc) set noclobber # aliases for all shells 'cd \!*;echo $cwd' 'cp -i' 'mv -i' 'rm -i' 'echo $cwd' 'rm -i'
set history=40 set ignoreeof #set notify #set savehist=40 #set prompt="% " #set prompt="`hostname`{`whoami`}\!: " #set time=100
CISC 1480/KRF Copyright 1999 by Kenneth R. Frazer
39
exit or logout
q q
40
Process Concepts
q q
q q q
Early or simple (DOS) computer systems allowed only one program to be executed at a time Modern computer systems like Unix are multitasking, allowing multiple programs to be loaded and executed concurrently This requires more control of programs, leading to the notion of a process A process is a program in some stage of execution A modern computer system is a collection of processes
u
Unix Processes
Every command executed on Unix is a process q Unix processes are hierarchical
q
u
42
Process Blocks
q
a process identifier the process state the value of the processs program counter other information specific to the process such as l memory limits l files in use l processor time used l ....
43
Sharing CPU by time-slicing and giving each active process a time slot May require paging and swapping as processes are activated or de-activated l Paging is a function of virtual memory that simulates a large, virtual memory map l Swapping is the process of moving a process out of memory to disk to free memory for another process
44
Command Components
q
Arguments are the things that the command will operate on q Options modify the behavior of the command
q
45
Command Notation
command name q [ ] optional arguments or options
q
u
| is an OR condition
u
46
who
q q
47
CALendar - cal
q q
Default is current year month - number from 1 to 12 year - number from 1 to 9999
Note: September 1752 is odd, 11 days were skipped to make up for lack of prior leap year adjustments q Examples:
q
48
date
Display or set the date q Syntax:date [-u] [-a [-] sss.fff] [yymmddhhmm [.ss]]
q
u u u
u - display date in GMT, default is local time a - slowly adjust system clock yymmddhhmm [.ss] - set system date and time l Only superuser can set the date and time
If the argument begins with a +, the output of date is under user control q Examples:
q
49
finger
Displays information about users q Syntax: finger [options] user_name q By default, finger displays user_names:
q
u u u u u u u
login name full name terminal name idle time login time location first line of .plan file
50
finger options
q q q q q q
-m Match arguments only on user name (not first or last name) -l Long output format -s Short output format -q Quick output format, only the login name, terminal, and login time are printed -i idle output format, only the login name, terminal, login time, and idle time are printed. -b Suppress printing the user's home directory and shell
51
Suppress printing the header Suppress printing the full name Suppress printing of the .project file Suppress printing of the .plan file
52
mail
Read or send electronic mail messages q Syntax: mail [-deHinNUv] [-f [filename | +folder] ] [-T file] or: mail [-dFinUv] [-h number] [-r address] [-s subject] recipient ... q First form is for reading mail, second is for sending mail q For this class:
q
u u u
Read mail: mail Send mail: mail -s subject recipient or: mail -s subject recipient < file_name
53
clyde% man ps clyde% man -k compile clyde% man -f /var/spool/mail clyde% man link clyde% man 2 link clyde% man 8 link
CISC 1480/KRF Copyright 1999 by Kenneth R. Frazer
54
whatis
Displays a one line summary about a command q Syntax: whatis command q Example:
q
clyde% whatis vi
55
apropos
Locate commands by keyword lookup q Syntax: apropos keyword q Example:
q
56
whois
q
Searches for a TCP/IP directory entry Used to find people or domain owners/contacts host - name of host computer to use for lookup l Default is nic.ddn.mil, which no longer supports anything but MILNET, Current host is rs.internic.net l Names are stored as last name, first name, titles
Examples:
clyde% whois -h rs.internic.net Earthlink.com clyde% whois -h rs.internic.net Krol, Ed*
57
show ProcesSes - ps
Displays the status of current processes q Syntax: ps [ [-] acCegjklnrSuUvwx] [-tx] | [num] [kernel-name] [c-dump-file] [swap-file] q Default is to display only processes with your effective user ID q We will only use the following options:
q
u u u
a - include processes that are not owned by you x - show processes that dont have a controlling terminal r - show only running processes
Example:
clyde% ps -a
58
talk
Talk to another user q Syntax: talk username [ttyname]
q
username - login name if on the same machine, username@machinename if on a different machine ttyname - login session to use if username is logged in more than once
59
talk Example
clyde% talk krf Message from Talk_Daemon@clyde at 17:39 ... talk: connection requested by krf@clyde.dcccd.edu. talk: respond with: talk krf@clyde.dcccd.edu Respond as shown and a split screen will be displayed with your input in one half and your talkmates output in the other q To end the session, type Control-c
q
60
MESsaGe - mesg
Permit or deny messages on your terminal q Syntax: mesg [n] [y]
q
u u u
default reports current state without changing it n - forbids messages to be sent to you from talk or write y - reinstates permission
61
write
Write a message to another user q Syntax: write username [ttyname]
q
username - login name of the message recipient ttyname - terminal name if user is logged in more than once Whatever you type is then copied, line by line, to the recipients terminal until you enter on EOF (control-d)
62
write Example:
clyde% write krf Hi there! Heard any good Unix jokes lately? control-d u On krfs terminal, the following appears: clyde% Message from krf@clyde on ttyp1 at 17:50 ... Hi there! Heard any good Unix jokes lately? clyde%
63
64
Disk Free - df
Reports amount of free disk space on file system q Syntax: df [-a] [-i] [-t type] [filesystem...] [filename...]
q
u u u u u
default is to report on all mounted file systems a - report on all file systems, including uninteresting ones with zero total blocks i - report number of used and free inodes, print * is no information is available t type - report on file systems of a given type, such as NFS filename - report space used by the file system containing filename
65
df Examples
clyde% df Filesystem /dev/sd0a /dev/sd0g /dev/sd0h /dev/sd0f kbytes 30807 204535 239391 425767 used 6462 180363 180222 296019 avail capacity Mounted on 21265 23% / 3719 98% /usr 35230 84% /home 87172 77% /usr/local
clyde% df my_file
/dev/sd0h 239391 180222 35230 84% /home
66
Disk Utilized - du
Displays the number of disk blocks used per directory or file q Syntax: du [-s] [-a] [filename]
q
s - only display grand total for each of the specified file names u a - display a value for each file
u
67
du Examples
clyde% du -a 3 ./.cshrc 3 ./.login 1 ./.sunview 3 ./.rootmenu 6 ./ttg_public 1 ./.plan 1 ./mail 10 ./.pinerc 1 ./.project 3 ./mbox 33 . clyde% du -s 33 . clyde%
CISC 1480/KRF Copyright 1999 by Kenneth R. Frazer
68
a - Report all option settings g - Report current settings in a format that can be used as an argument to another stty command\
To set the erase command to be a backspace: clyde% stty erase ^h Key mapping good candidate for inclusion in your .login file
69
stty Examples
clyde% stty speed 38400 baud; evenp -inpck imaxbel -tabs iexten crt clyde% stty -a speed 38400 baud, 0 rows, 0 columns parenb -parodd cs7 -cstopb -hupcl cread -clocal -crtscts -ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc ixon -ixany -ixoff imaxbel isig iexten icanon -xcase echo echoe echok -echonl -noflsh tostop echoctl -echoprt echoke opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tabs erase kill werase rprnt flush lnext susp intr quit stop eof ^? ^U ^W ^R ^O ^V ^Z/^Y ^C ^\ ^S/^Q ^D clyde% stty -g 2526:1805:1af:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16:0
CISC 1480/KRF Copyright 1999 by Kenneth R. Frazer
70
mail(pine)
PINE 4.10 ? HELP C COMPOSE MESSAGE I MESSAGE CHECK MAIN MENU Folder : INBOX No Messages - Get help using Pine - Compose and send a message - View messages in current folder - Select a folder to view - Update address book - Configure Pine Options - Leave the Pine program
? Help
P PrevCmd
R RelNotes K KBlock
71