unix overview - special manpower development program for vlsi
TRANSCRIPT
UNIX Overview
Presenter : Raj Singh
IC Design GroupCEERIPilani – 333 031
Phone : 01596-242359
Fax : 01596-242294
Email : [email protected]
UNIX Overview History
UNIX History
• In 1969 by Thompson and Ritchie — ACM Turing award in 1983.
• Objective was to provide a programming environment of unusual simplicity,power and elegance.
• 1969 :? AT&T leaves MULTICS project.? New OS project proposals by Thompson, et al. in limbo.? Basic design of file system by Thompson, Canaday and Ritchie.? PDP-7 used to implement basic file system and shell.
c©CEERI, Pilani IC Design Group 1
UNIX Overview History
�
�
UNIX History
• 1970 :? Kernighan suggested the name UNIX (as a pun on MULTICS) for single-user OS.? I/O redirection.? Proposal for PDP-11 for text editing and formating (US $ 65K).? PDP-7 UNIX enhanced as PDP-11 shipment delayed.
• 1971 :? “Word Processing” software offered to Bell Lab’s Patent Department.? Plans to acquire PDP-11/45.? Thompson wanted to offer FORTRAN, but came up with B.? PDP-11 UNIX started with B. Initial work on what was to become C.
(BCPL → B → C).
c©CEERI, Pilani IC Design Group 2
UNIX Overview History
�
�
UNIX History
• 1972 :? Pipes (initially >< then |).? C comes into being.
• 1973 :? UNIX kernel written in C.? Multi-user UNIX.
• 1975 : UNIX given to Universities at no charge and no support (6th edition). Start of BSDversions.
Before 1977, UNIX ran only on PDP-11s.
c©CEERI, Pilani IC Design Group 3
UNIX Overview History
�
�
UNIX History
• 1978 : First commercial sale of UNIX (7th edition).
• 1980 : UNIX System III.
• 1982 : UNIX System V; BSD 4.2.
• 1986 : UNIX System V.3; BSD 4.3.
• 1991 : UNIX System V.4.1 (Converged UNIX).
• 1992 : UNIX System V.4.2 (UNIX with icons); BSD 4.4.
c©CEERI, Pilani IC Design Group 4
UNIX Overview Versions
Versions of UNIX
• AT&T Versions : 7th Edition, System III, System V
• Derived Versions : 4.x BSD, HP-UX, Ultrix, XENIX, VENIX, etc.
• Look-alike Versions : PNX, QNX, Regulus, Idris, AEGIS, UNETix, UNOS,Cromix, etc.
c©CEERI, Pilani IC Design Group 5
UNIX Overview Structure
UNIX Structure
PROGRAMS
APPLICATIONPROGRAMS
PROGRAMSUSER
PROGRAMSAPPLICATION
USERPROGRAMS
USER
UTILITIES
UTILITIES
SHELL
KERNEL
SHELL
c©CEERI, Pilani IC Design Group 6
UNIX Overview Popularity ?
Why was/is UNIX Popular ?
• Portable – Over 95% Code in C.
• Multi-user Operation.
• Background Processing.
• Hierarchical File System.
• UNIX Shell(s).
• Pipes and Filters.
• Text Processing Tools.
• Software Development Tools.
• Mature Operating System.
c©CEERI, Pilani IC Design Group 7
UNIX Overview Some Comments
Some Comments on UNIX
+ Easy to use but not easy to master.
− Very difficult to use.
+ Logical and sensible.
− Illogical and makes no sense.
+ Best system for software development.
+ Learn concepts, don’t memorize details.
+ Love its terse commands and messages.
− Hate its terse commands and messages.
c©CEERI, Pilani IC Design Group 8
UNIX Overview Utilities
UNIX Utilities
• File Management.
• Software Development.
• Office Support.
• Network Support.
• Text Processing.
• General System Operation.
• Games.
c©CEERI, Pilani IC Design Group 9
UNIX Overview Getting Started
Getting Started
• Super User.
• Ordinary User.
• Group Name.
• Log-in, Password.
• Log-out.
• Default Shell.
• Home Directory.
• Working Environment.
c©CEERI, Pilani IC Design Group 10
UNIX Overview Customization
Customizing Your Environment
.cshrc : Initial instructions for C-shell.
search path, cd path, aliases, prompt, set, setenv, history, etc.
.exrc : Initial commands and options for editor.
.history : Command history of last session.
c©CEERI, Pilani IC Design Group 11
UNIX Overview Customization
�
�
Customizing Your Environment
.login : Login instructions. Terminal setting, options setting, greetings, etc.
.logout : Logout instructions. Good-bye message, House-keeping type ofcommands, removing junk files, etc.
.profile : Initial instructions for Bourne-shell.
More rc files also exist for other tools and utilities e.g. .mailrc, .dvipsrc.
c©CEERI, Pilani IC Design Group 12
UNIX Overview Files
File System and Commands
Everything in UNIX is a file. A file is a sequence of bytes — the meaning of the bytes dependssolely on the programs that interpret the file.
• Create a file : ed, vi, cat
• What’s in a file : file, od, wc, dd
• Remove a file : rm
• Copy a file : cp
• Move/Rename a file : mv
• View a file : cat, head, tail, vi
• Concatenate files : cat
c©CEERI, Pilani IC Design Group 13
UNIX Overview Files
�
�
File Commands
• Compare files : diff, diff3, cmp, comm
• Split a large file : split
• Archive files : ar, tar, mcopy
• Miscellaneous : cut, paste, sort, uniq, grep, find, touch, chown, chgrp, gzip
• Change access mode of a file : chmod
c©CEERI, Pilani IC Design Group 14
UNIX Overview Files
File Attributes
Every file has a set of permissions (or access mode) associated with it.
These permissions determine who can do what with the file.
−︸︷︷︸
− file
d directory
c, b special
rwx︸︷︷︸
u
rwx︸︷︷︸
g
rwx︸︷︷︸
o
1︸︷︷︸
links
bin︸︷︷︸
owner
8454︸ ︷︷ ︸
bytes
c©CEERI, Pilani IC Design Group 15
UNIX Overview Directories
Directory System
• Powerful organization tool.
• Each program has a current directory.
• Absolute path.
• Relative path.
• Current directory.
• Parent directory.
• Home directory.
c©CEERI, Pilani IC Design Group 16
UNIX Overview Directories
Directory Structure
root
bin dev etc lib sys home . . .
anil . . . gopal . . . . . .
prog report util
asm p
algo.c . . . try.c
memo warp
usr
you
c
. . .
c©CEERI, Pilani IC Design Group 17
UNIX Overview Directories
Directory Commands
• Create directory : mkdir
• Remove directory : rmdir, rm -r
• List directory contents : ls
• Change directory : cd
• Print working directory : pwd
• Directory compare : dircmp
Current directory is .
Parent directory is ..
Home directory is ~
c©CEERI, Pilani IC Design Group 18
UNIX Overview Directories
Some Interesting Directories
/ root of the file system/bin essential executables/dev device files/etc system miscellany/lib essential libraries/tmp temporary files/usr user file system/usr/adm system administration/usr/bin user binaries/usr/games game programs/usr/include header files for programs/usr/lib lib for C, F-77, . . ./usr/local local files/usr/man on-line manual/usr/spool communication programs/usr/src code of some programs/usr/tmp alternate tmp directory/usr/ucb programs from UC-Berkeley
Partial changeover was made to /var for some directories in late 1990s.
c©CEERI, Pilani IC Design Group 19
UNIX Overview Editors
Editors
• Line editor : ed
• Screen editor : vi
• Line editor with vi : ex
• Stream editor : sed, tr
The editors do not change the file directly.
Mode vs. Modeless Editors.c©CEERI, Pilani IC Design Group 20
UNIX Overview Input/Output
Input/Output
• Standard input (0) : usually keyboard.
• Standard output (1) : usually screen.
• Standard error (2) : usually screen.
Redirection tells the command where to redirect its input, output, or error.
% who > logusers$ cat < textfile$ sort < users > sorted_users
>> appends, >! forces overwriting.
<< takes input till specified point.
c©CEERI, Pilani IC Design Group 21
UNIX Overview Input/Output
�
�
Input/Output
• Pipe : Take output from one command and feed it into the input of another command.
% who | sort -r% ls | wc -l
• Filter : Any program that takes it input from standard input, performs some operation onit, and writes its result to standard output.ls, cd, pwd, who are not filters.cat, sort are filters.
• Tee : Copies data coming on the standard input to standard output and also copies it inthe specified file.
$ who | tee save | sort -r | tee rsave
c©CEERI, Pilani IC Design Group 22
UNIX Overview Shells
Shell Features
• Bourne Shell : The original shell developed by S. Bourne is also calledBell Shell. Usually denoted by sh and prompt as $.
• C Shell : Standard shell with BSD versions was developed by W. Joy.Named for its C-like constructs. Usually denoted by csh and prompt as %.
• Korn Shell : The standard shell with the newer releases of UNIX. Com-bines features of sh and csh, and has additional features. Usually denotedas ksh.
• Other Shells : Visual shell, Restricted shell, Functional shell, ExtendedShell, . . .
c©CEERI, Pilani IC Design Group 23
UNIX Overview Shells
Shell Responsibilities
• Program execution.
• Meta-character substitution.
• I/O redirection.
• Pipeline hookup.
• User environment control.
• Group commands.
• Programming language.
c©CEERI, Pilani IC Design Group 24
UNIX Overview Development Environment
Software Development
• Shell interpreters : csh, sh, ksh
• Compilers : cc, pc (pas), f77, lisp, . . .
• Program checking : lint
• Debugging : sdb, ctrace, cflow, cxref, prof, dbxi, gdb
• Compiling dependent programs : make
• Lexical analyzer : lex, flex
• Parser generator : yacc, bison
• Miscellaneous : awk, sccs, time, . . .
c©CEERI, Pilani IC Design Group 25
UNIX Overview Other Support
Office and Networking Support
• Calendar of month, year : cal
• Reminder Service : calendar
• Electronic mail : mail, talk, write
• Calculator : bc
• Units conversion : units
• Prime factors : factor
• Network-related : rlogin, ftp, telnet, rsh, uucp, rfs, nfs, ping, cu, . . .
c©CEERI, Pilani IC Design Group 26
UNIX Overview Text Processing
Text Processing
One of the first applications of UNIX was editing and formatting documents.
The first text formatter was roff.
The next formatter nroff was programmable (written by J. Ossanna). In 1973, this was ex-tended to troff to support type-setting using multiple fonts and sizes.
• macro packages : ms, me, mm.
• preprocessors : tbl, pic, eqn.
• utilities : spell, style, diction, refer.
c©CEERI, Pilani IC Design Group 27
UNIX Overview Utilities
General Utilities
• Foreground/Background : fg, bg
• Kill a process : kill
• Change job priority : nice
• Process status : ps
• Printer Control : lpr, pr, lpc
• Continue executing after logout : nohup
• Commands at a particular time : at
c©CEERI, Pilani IC Design Group 28
UNIX Overview Utilities
�
�
General Utilities
• Current date, time : date
• User details : finger
• List of logged-in users : who
• Disk Usage details : du, df
• Which command : which
• Command summary : where, what
• Command manual page : man
• History of commands : history
c©CEERI, Pilani IC Design Group 29
UNIX Overview Games
Games
• Arithmetic skills : arithmetic
• Treasure hunt : adventure, hack, rogue
• Backgammon : bgm, gammon
• Patience : canfield
• Word Building : boggle, hangman
• Fortune telling : fortune, ching
• Number guessing : mind, moo
• Quiz on various topics : quiz
. . . and many more . . .
c©CEERI, Pilani IC Design Group 30
UNIX Overview References
Books and Reference Material
• UNIX (or Solaris or Linux) Manuals.
• B. Kernighan and R. Pike, The UNIX Programming Environment, PHI, 1982.
• M. Bach, The Design of UNIX Operating System, PHI, 1986.
• S. Prata, Advanced UNIX : A Programmer’s Guide, Sams, 1985.
• S. Kochan and P. Wood, Exploring the UNIX System, Hayden, 1989.
• S. Kochan and P. Wood, UNIX Shell Programming, Third Edition, Sams, 2003.
• A. Robbins, UNIX in a Nutshell, Fourth Edition, ORA, 2005.
Books on awk, lex, yacc, nroff and other UNIX utilities are also available from O’Reillypublishers. Indian editions are by Shroff Publishers.
c©CEERI, Pilani IC Design Group 31