Coverage: Chapter 1,and also Chapter 1(pp. 3-20)and Appendix A.1 (pp. 797-800)

What is UNIX?

an operating systemwhat is an operating system?

Hallmarks of UNIX

multiuser, preemptive multitasking (time-shared), interactive, portable (created in C), accessible (nohup, dump process table), text-based, terse, efficient, silent, and free!

Historical perspective

initially units programs were composed in assembly language research study in the 1960"s result in BCPL and also then C UNIX arisen in the late 1960"s (Ken Thompkid, 1969, Bell Labs, follower to MIT"s Multics) UNIX recomposed in C in the early on 1970"s C is a `low" high-level programming language; WYSIWYG (What You See Is What You Get) the marital relationship of UNIX in C offered an idealatmosphere for units programming the majority of systems programming today is still done in UNIX and C

The UNIX philosophy

(communication) model: write a solution to a problem by combining several small, atomic programs in artistic ways through interprocedure interaction and also interoperability mechanisms, such as pipes atomic programs are the structure blocks interaction mechanisms are the glue such programs are less complicated to develop, debug, and also maintain than large, all-encompassing, monolithic systems `If you provide me the appropriate sort of Tinker Toys, I have the right to imagine thestructure. I have the right to sit tright here and see primitives and also recognize their power to buildframeworks a fifty percent mile high, if just I had just an additional to make itfunctionally complete" -- Ken Thompson, creator of UNIX and also the 1983 ACM A.M. Turing Award Recipient, quoted in IEEE Computer 32(5), 1999. (concurrency) processes deserve to clone themselves (with fork) why would you desire to carry out this? think of programs you use everyday turns out to be an very powerful and valuable primitive unicreate style of I/O we will certainly view these themes recur throughout this book

OOP vs. Linux design of programming/trouble solving

Key: ◯ = object, ▢ = process, → = message or information, or = thcheck out, and ~ = pipe.

You are watching: Today, virtually all new major operating systems are written in:

Object-oriented modelof programming/difficulty solvingUNIX version of programming/difficulty solvingsequentialparallelre-compilere-configure

History of UNIX and also C

1967 Martin Richards establishes BCPL as a language for writing operating units and compilers Ken Thompchild creates B, which B evolved from BCPL,at AT&T Bell Laboratories in Murray Hill, NJ both B and also BCPL were typeless languperiods (i.e., every data item lived in one word in memory) 1969 Ken Thompson offered B to develop early version of the UNIX operating mechanism on a DEC PDP-7 computer at Bell Labs in Murray Hill, NJ. UNIX developed from Multics, also at Bell Labs B ended up being commonly well-known as the advance language of the UNIX OS 1972 Dennis Ritchie wrote a C compiler at Bell Labs advanced from B originally applied on a DEC PDP-11 computer system thought about a hybrid in between a low-level language and also a high-level language; provides programmer infrastructure to allocate and manipulate memory fantastic for writing systems programs (e.g., compilers), yet for other programs C is not the ideal choice it does not babysit the programmer via numerous automatic checks no training wheels (no undelete) 1973: Dennis Ritchie helped Thompboy port UNIX to a DEC PDP-11; they recomposed the UNIX kernel in C 1974 they licensed UNIX to colleges and also universities for educational functions significant role in the breakthrough of UNIX and C `four-year effect" later on UNIX end up being available for commercial use Computer "Systems" Research Group at UC Berkeley (UCB) made considerable additions and also changes UNIX developers break-up into 2 camps UCB camp (west coast) resulted in BSD (Berkeley Software Distribution), 4.xBSD Berkeley UNIX, Ultrix (DEC"s UNIX, based upon BSD 4.2), SunOS, FreeBSD (based on 4.4BSD-Lite) vi editor AT&T Bell Labs & UNIX SystemsLaboratories (USL) camp (east coast): resulted in SVR3 1983: Ken Thompson and also Dennis Ritchie are provided the ACM A.M. Turing Awardfor contributions to OS concept and also the implementation of UNIX 1987: AT&T Bell Labs and Sun Microunits wanted to merge BSD and also System V which led to SVR4 (arisen jointly by USL and Sun) trying to merge this particular day, want an extra traditional version, continuous job-related on POSIX C developed right into C++ (the ++ creates a pun) today virtually all brand-new significant OS"s are composed in C/C++ UNIX is not an acronym, but a weak pun on Multics -- the OS Thompboy and also Ritchie functioned on before UNIX

Conceptual UNIX architecture

hardware kernel shells (e.g., sh, ksh, bash) compilers gcc - gives a digital C computer g++ - gives a digital C++ computer programs and also applications (e.g., cat, wc, sed, awk) X-windows system


UNIX®: a multiuser, preemptive multitasking (time-shared), hierarchical file framework operating systemhallmarks of UNIX:time-shared, multi-user, portable (composed in C),easily accessible, interenergetic,text-based, terse, efficient, silent, free!logging onenter your login name (echoed to screen), hit enter,enter your password(not echoed), hit enter(some UNIX systems will certainly initially requirethe user to develop a password for a brand-new account)the password are changed by execution of thepasswd utility program.logging out:hit or enter exit

Accessing your UNIX account

ssh"inglogin procedure login name echo"ed password not echo"ed if you enter an invalid string for either, the mechanism will certainly not show which was invalid concept of the shell: your interchallenge to the systemls"ing, clearbc -l (an arbitrary precision calculator)some mechanism status commands: day,hostname, whoami (or logname),who, w, uptime (when was thesystem last rebooted),uname and uname -a,ulimit and ulimit -a(ulimit is a shell builtin),ps and also ps -a, andpeak and htop

General syntaxes of UNIX commands

> >examples: $ ls $ ls -l # dislays total # of blocks; block = 1/2k (512 bytes) $ ls -l myfile $ ls -ld mydir $ ls -F mydir $ ls -al $ ls -a -l # POSIX compliant $ ls -l -d mydircommand also names (prefer filenames) are case sensitive

Getting aid on the UNIX system

for a assist on a certain command also, useguy command>male retrieves the manpage (hand-operated page) forany type of command also, C library function, or system callfor circumstances, man wc, man -s 3C printf,man fgand so on, guy fork, orguy man (a self-referential command)for all commands on a basic topic, useaproposapropos keyword/topic> (e.g.,apropos copy)apropos = male -k whatis = male -f title> manpage deserve to be searchedthrough /keyword/topic> male printf (which section?) usage guy -a printf (all) man -s 2 fork male -s 3 intro

UNIX manual

Ch1: Commands Ch2: System Calls Ch3: Libraries (portable, meet a standard C specification) Ch4: File Formats Ch5: Misc Facilities, macros Ch6: Games Ch7: Devices and also Netfunctioning Ch8: System Maintenance Ch9: Device Drivers$ man man The table listed below mirrors the section numbers of the hand-operated complied with by the kinds of pages they contain. 0 Header documents (generally found in /usr/include) 1 Executable programs or shell commands 2 System calls (features offered by the kernel) 3 Library calls (functions within regimen libraries) 4 Special records (normally found in /dev) 5 File formats and also conventions eg /etc/passwd 6 Games 7 Miscellaneous (consisting of macro packages and conven- tions), e.g. man(7), groff(7) 8 System administration commands (generally only for root) 9 Kernel routines

POSIX: UNIX standards

POSIX (Portable Operating System Interface) IEEE conventional for UNIX libraries to promotethe breakthrough of trusted software Linux, Mac OS X, and also many other spices of UNIX are moving towardPOSIX standards (e.g., POSIX threads)

Introductionto the vi editor and philosophy

the vi ideology editors such as vi and also emacsare editors for programmers and power-users;they were designed for world who desire to be extremely reliable andproductive in their workwhy do the h,j,k,lsecrets correspond to left, dvery own, up, right arrow secrets, resp.?bereason it is much faster for the typist to reach theh,j,k,l keys than the arrowhead keyswe study vi given that it is the only editor guaranteed to exist on allUNIX systemsthere is a steep discovering curve, yet theincrease in productively is worth the investmentvi is a moded editor and can be in among the complying with three settings at any type of one time:vi command also mode (for cursor motion and also message deletion)vi insert/input/editing mode (for entering text)vi ex mode (all commands starting via a colon)to start vi, enter vi filename(s)>(if file(s) does not exist, vi creates it/them) view file(s)> (open file(s) as read-only) vi +n file(s)>as soon as vi is initially began, it is in command also mode (i.e.,all keystrokes gone into are understood as commands)usage h,j,k, l keys to moveleft, dvery own, up, right, resp., why?crtl-u> (pageup); crtl-d> (pagedown),and crtl-l> (repaints the screen)to go back to commandmode from insert mode, hit esc> u essential undoes the previous procedure r vi is developed on peak of ex and also exis built on peak of edethe original UNIX line editor);(ed ⊂ ex ⊂ vi);hitting ":" while in command also mode permits the user toenter ex commands :w (file write) :q (quit, no write) :wq = shift-ZZ> (file write and also quit) approaches to studying: memorize regulates orlearn/recognize basic syntaxbasic syntaxation of vi commands:operator> object> 3x (delete 3 characters) d^ (delete earlier to start of line) basic syntaxation of ex commands::
> command>> :g/^$/d (deletes all blank lines) vim is vi enhanced $ vimtutor

vi editor examples

notice just how the following commands follow the general syntaxes above: x crucial deletes a single character dd (delete 1 line) 3dd (delete 3 lines) yy (yank) p (paste) 3p (paste 3 lines) rc (replace char through c) :collection showmode :set noshowmode :set number (or :collection nu for short) :collection nonumber (or :collection nonu for short) :set relativenumber :801 (go to line 801) :set leader showmode showcomplement :collection ts=3 expandtab :set wrapshave the right to wrapmargin=1 (for wordwrap) :set list (display screen each TAB as ^Is and also EOLs as $) :set nolist :syntaxation on :syntaxes off :r file> (reads file through filename file> right into buffer) :r !command> (reads typical output of command> into buffer) search and also replace: :%s/search_text/replacement_text/g (same as 1,$s/RE/replacement_text/g); examples: :%s/Alice/Lucy/g (the g renders it global,i.e., rearea all cases, not just the first, on each line) :%s/fprintf/FPRINTF/g (relocations all cases of fprintf via FPRINTF) :%s/fprintf/FPRINTF/gc (relocations all incidents of fprintf through FPRINTF,requires confirmation) we will certainly go a lot deeper into vi as the book progresses

vi editor reference

the following regulates put vi into insert/input mode;table gives theposition wright here the message is inserteddescriptioninsert text
prior to cursori
at beginning of lineI
after cursora
at end of lineA
after existing lineo
prior to current lineO
vi referral table (in command also mode)descriptioncommand code
relocate one space to the rightspace, l, or best arrow
relocate one area to the lefth, or left arrow
move dvery own one linej, or dvery own arrow
move up one linek, or up arrow
relocate one word to the rightw, or W
move one word to the leftb, or B
move to beginning of line0
move to end of line$
relocate to top of screenH
move to middle of screenM
move to bottom of screenL
save contents to file:w
quit file:q
quit vi, conserving file just if changes were made:x
save file and also quit vi:wq
save contents to file and quit viZZ
toggle in between uppercase and lowercase~
delete earlier one characterX
delete character under cursorx
delete linedd
delete worddw


B.W. Kernighan and also D.M. Ritchie. The C Programming Language.Prlure Hall, Upper Saddle River, NJ, 2nd edition, 1988.
B.W. Kernighan and also R. Pike. The UNIX Programming Environment.Prattract Hall, Upper Saddle River, NJ, Second edition, 1984.

See more: Why Were The Soviets Troubled When Hungary Withdrew From The Warsaw Pact?

Robbins and S. Robbins.UNIX Solution Programming:Conmoney, Communication, and also Threads.Prlure Hall, Upper Saddle River, NJ, 2nd edition, 2003