Unix I
INFO1-CE9545 Section 1
http://i5.nyu.edu/~mm64/INFO1-CE9545/

Lectures 6 through 8 of this course constitute the subcourse Regular Expressions INFO1-CE9960.

Syllabus, grading policy, and catalog description

Here’s the syllabus and grading policy that I submit to NYU. I also wrote the following catalog description, but NYU edited it for INFO1-CE9545 and Y12.1005.

Get the foundational skills to go farther in the Unix world: networking, programming, or system administration. Create files and directories; copy, move, rename, search, archive, compress, and remove them; read- and write- protect them; and connect them with hard and symbolic links. Connect programs to files and to other programs with i/o redirection. Compose Unix command files (shellscripts) with command line arguments, pipelines, loops, conditional statements, file descriptors, and exit status. Personalize your Unix account with environment variables, aliases, startup scripts, and your own versions of existing Unix commands. Control a running process with the Korn shell, and learn to schedule, start, stop, and kill it. Use regular expressions to search, edit, and transform data with the utilities grep, sed, awk, and the vi text editor; protect source code with CVS. Host HTML forms and CGI scripts on a Sun (now Oracle) Solaris box. Prerequisites: none.

How far did we get in the Handouts?
What’s the homework?

  1. Wednesday, June 5, 2013: up to Handout 1, p. ???. Are there any corrections to the Handouts yet? Read the syllabus and grading policy. See how much homework there was last semester. Can you see the Handouts and Unix manual online? Print Handout 1 from your web browser, and, on June 12, also Handout 2. Bring both Handouts with you on June 12.

    Get a Unix book if you don’t already have one. I recommend The UNIX Programming Environment by Kernighan and Pike; buy it used on Amazon.

    Get your loginname (same as your NYU NetID) and secret password, if you don’t already have them, for our Unix machine i5.nyu.edu. If you couldn’t get a secret password from start.nyu.edu, contact the accounts office. One way to do this is by calling (212) 998-3333.

    To log into i5.nyu.edu from a PC, you will need a communications program that speaks the Secure Shell (ssh) protocol. One example is PuTTY. If you don’t already have PuTTY, you can download it free from its website or from NYU. You can also log into i5.nyu.edu from a lab on campus, or from the iPhone app TouchTerm, or from the iPhone or iPad app pTerm, or from the Android app ConnectBot. (iPhone users: is it worth paying for TouchTerm Pro?)

    To log into i5.nyu.edu from another Unix system, (i.e., from the Terminal application of a Mac OS X), you will need the Secure Shell client ssh. If you don’t already have it, download a free copy and run the following command, typing your loginname in place of abc1234.

    ssh abc1234@i5.nyu.edu
    

    You can also install VirtualBox on your PC or Mac, and then install one or more versions of Linux into VirtualBox. Follow these instructions to install VirtualBox and (for example) Fedora Linux. Please email me at mark.meretzky@nyu.edu if anything needs to be updated in the instructions (e.g., the version numbers of the files). Thanks.

    For wireless in 7 East 12th Street, room 228, the name is guest501. The password is different each week; get it from the information desk at the entrance of the building, or from room 233.

    Read the rest of Handout 1 and start looking at Handout 2. Play with all this stuff. Try every example. Do they actually work? Do they still work on another Unix box? Look at the online manual. Do Homework 1.1, but don’t hand it in. Email me at mark.meretzky@nyu.edu if you get into trouble. The other courses that I teach are listed on my home page. Watch the other students in the class change from red to black as they log in. Click on the tip of each nose in the class photo.

  2. Wednesday, June 12, 2013:
  3. Wednesday, June 19, 2013:
  4. Wednesday, June 26, 2013:
  5. Wednesday, July 3, 2013:
  6. Wednesday, July 10, 2013:
  7. Wednesday, July 17, 2013:
  8. Wednesday, July 24, 2013:
  9. Wednesday, July 31, 2013:
  10. Wednesday, August 7, 2013:

Summer 2012 Homework

Please bring a cellphone to the first class to take the class photo.

  1. Tuesday, May 22, 2012: up to Handout 1, p. 8. Are there any corrections to the Handouts yet? Read the syllabus and grading policy. See how much homework there was last semester. Can you see the Handouts and Unix manual online as in Handout 1, p. 16? Print Handout 1 from your web browser, and, on May 29, also Handout 2. Bring both Handouts with you on May 29.

    Get a Unix book if you don’t already have one. I recommend The UNIX Programming Environment by Kernighan and Pike; buy it used on Amazon.

    Get your loginname (same as your NYU NetID) and secret password, if you don’t already have them, for our Unix machine i5.nyu.edu. If you couldn’t get a secret password from start.nyu.edu, contact the accounts office. One way to do this is by calling (212) 998-3333 option 1.

    To log into i5.nyu.edu from a PC, you will need a communications program that speaks the Secure Shell (ssh) protocol. One example is PuTTY. If you don’t already have PuTTY, you can download it free from its website or from NYU. You can also log into i5.nyu.edu from a lab on campus, or from the iPhone app TouchTerm, or from the iPhone or iPad app pTerm, or from the Android app ConnectBot. (iPhone users: is it worth paying for TouchTerm Pro?)

    To log into i5.nyu.edu from another Unix system, (i.e., from the Terminal application of a Mac OS X), you will need the Secure Shell client ssh. If you don’t already have it, download a free copy and run the following command, typing your loginname in place of abc1234.

    ssh abc1234@i5.nyu.edu
    

    You can also install VirtualBox on your PC or Mac, and then install one or more versions of Linux into VirtualBox. Follow these instructions to install VirtualBox and (for example) openSUSE Linux. Please email me at mark.meretzky@nyu.edu if anything needs to be updated in the instructions (e.g., the version numbers of the files). Thanks.

    For wireless in 7 East 12th Street, room 228, the name is guest501. The password is different each week; get it from the information desk at the entrance of the building, or from room 233.

    Read the rest of Handout 1 and start looking at Handout 2. Play with all this stuff. Try every example. Do they actually work? Do they still work on another Unix box? Look at the online manual. Do Homework 1.1, but don’t hand it in. Email me at mark.meretzky@nyu.edu if you get into trouble. The other courses that I teach are listed on my home page. Watch the other students in the class change from red to black as they log in. Click on the tip of each nose in the class photo.

  2. Tuesday, May 29, 2012: up to Handout 2, p. 16. Are there any corrections to the Handouts yet? Play with everything. Do Homeworks 1.2 and 1.3, but don’t hand them in. Hand in Homework 1.4 and 1.5; print your file using a web browser rather than with the lpr program.

    Look at the files /etc/motd, /usr/pub/ascii, and /usr/dict/words. Look at the seven fields of your line in /etc/passwd. Find the name of your group in /etc/group.

    Play with cp, mv, rm, and ln (hard and symbolic). Do Homeworks 2.2 and 2.3, but don’t hand them in.

    You probably have Unix accounts on several machines. Which shell is launched automatically when you log into each account? Copy ~mm64/public_html/INFO1-CE9545/src/.profile into your home directory, log out, and log back in. Does your prompt now have an increasing number? Do the shortcuts in Handout 2, pp. 11–12 now work? Do you now have the aliases and variables in pp. 13–14?

    Bring a printout of Handout 3 (and Handout 2) with you on June 5th so you can take notes, and in general bring the current handouts to class. The Transit of Venus will begin in New York City at 6:03:39 pm EDT on Tuesday, June 5. At that time, the Sun will be going down in the west.

  3. Tuesday, June 5, 2012: up to Handout 3, p. 13. Admire all the useful things I put in your .profile file: noclobber, ignoreeof, set showmode, etc.

    Open up two Unix shell windows to i5.nyu.edu, using ssh on Mac or putty on PC. Say who and make a note of the your two (pseudo-)terminals in the /dev/pts directory of i5.nyu.edu. Observe that you temporarily become the owner of a terminal while you’re using it, and that root (the superuser) becomes the owner again when you log off from the terminal. Chmod your terminal to rw--w---- if it does not already have these settings. Can you run a program (e.g., echo) in one window and send its standard output to the other window? Can you run a program (e.g., cat) in one window and have it draw its standard input (or at least every other line of its standard input) from the other window?

    Find all the block and character hardwarde devices on i5.nyu.edu and on your other Unix box(es) using the find program Handout 2, p. 19, last line 5. Who owns the disk drives? To whom has the owner given read and write permission for the disk drives?

    Feed standard input into bc (Handout 2, p. 21) from the keyboard, and indicate the end of input with control-d. Mail yourself two letters. Type them in from the keyboard and indicate the end of input with control-d. Then read your mail.

    Practice vi and vim. When you think you have about a 75% chance of editing a file successfully and saving it to the disk without destroying it, do Homeworks 3.1 and 3.2, but don’t hand them in. Emacs users should do Homework 3.3 if they do not already have an .emacs file in their home directory.

    Look at the DirectoryIndex and UserDir lines in the Apache web server configuration file /etc/apache/httpd.conf. Do Homework 3.4, but don’t hand it in. Then click on each nose in the class photo, and grep for your loginname in /var/apache/logs/access_log.

    Do Homework 3.5, but don’t hand it in. Then visit http://i5.nyu.edu/~mm64/INFO1-CE9545/bio/. Hand in Homework 3.6. Read ahead in Handout 3 and even Handout 4.

  4. Tuesday, June 12, 2012: up to the end of Handout 3. Look at your PATH environment variable in all your Unix accounts. What directory holds date, cal, ls, etc., in all your Unix accounts? The files that are executed when you log in are in “Invocation” on p. 52 of the Korn Shell manual page; see also p. 2 of the Bash Shell manual page.

    Hand in Homeworks 3.7, 3.8, and 3.9. Do Homeworks 3.10, 3.11, and 3.12, but don’t hand them in. For a preview of the for loops in Handout 4 and the `back quotes` in Handout 5, see myping.

  5. Tuesday, June 19, 2012: up to Handout 4, p. 18. Hand in Homework 4.1. Look at the variables created in your .profile file; most of them are environment variables. We saw the TERM environment variable in Handout 3, p. 1. Run the Perl program in Handout 4, p. 6 and the Java program in Handout 4, pp. 5–6, but don’t hand them in. Then update your résumé to say “Unix/Perl/Java”. I added a Python example on p. 7. Play with for loops. Hand in Homework 4.2. Play with awk. Read ahead about if statements in Handout 4.
  6. Tuesday, June 26, 2012: up to Handout 5, p. 10. Play with if statements. Hand in Homeworks 4.3 and 4.5. (You only have to hand in one copy of post for the two homeworks.) Do Homework 4.4 (exit status), but don’t hand it in. Play with while loops. Hand in Homework 5.1. Do Homework 5.2 (set -x), but don’t hand it in. Hand in Homework 5.3; use awk if you can, perl if you must.

    Put an image file into your public_html directory, and then display the image in your index.html file. No class July 3rd.

  7. Tuesday, July 10, 2012: up to Handout 5, p. 30. Do Homeworks 5.3, 5.4, 5.5, 5.6, but don’t hand them in. Hand in Homework 5.7. Play with `back quotes`. The one-line summary of everything in Section 1 of the online manual (Handout 2, pp. 2–3) is here (Handout 5, p. 18). Hand in Homeworks 5.8 and 5.11.
  8. Tuesday, July 17, 2012: up to Handout 6, p. 13. Does the gateway here work yet? To see the list of signals, one per line and numbered starting at zero,
    kill -l | tr ' ' '\012' | awk '{print NR-1, $0}'
    
    If you have an account on another Unix machine, hand in Homework 6.1. Show your shell, the parent of your shell, the parent of the parent, etc., going back as far as you can. Can you go all the way back to the process whose PID number is zero?

    Practice going back and forth between two vis, copying and pasting. Look at the alias for jobs in your .profile file.

    Play with the grep gateway and the Ruby gateway. If you’re interested in MySQL, look at the example. (You would have to get a MySQL password for i5.nyu.edu if you wanted to try it yourself.) Isn’t it sad that IMDB doesn’t have regular expressions any more? Hand in homeworks 6.2, 6.3, 6.4, 6.5, and 6.6.

  9. Tuesday, July 24, 2012: up to Handout 7, p. 13. Hand in Homeworks 6.7, 6.8, and 7.1. Put a touch-sensitive image in your web page on i5.nyu.edu, but don’t hand it in. While you’re at it, you can say “Welcome, visitor number 151,324.” Create your own version of rm, but don’t hand it in. Read the manual page for at on your other Unix machine, and try the wee example in Handout 7, p. 7 on your other machine.

    If you have not yet emailed your course evaluation to NYU, please go here and login with your NetID/Password.

  10. Tuesday, July 31, 2012:

Errors in the Summer 2013 Handouts

Handout 1

Handout 2

Handout 3

Handout 4

Handout 5

Handout 6

Handout 7

Handout 8

Handout 9

Handout 10

Handout 11

Handout 12

Instructional materials

  1. The Handouts are the textbook for this course.
  2. The recommended Unix book is The Unix Programming Environment by Brian W. Kernighan and Rob Pike; Prentice-Hall, 1983; ISBN: 0-13-937681-X. Get it at Amazon.
  3. Links to files of data.
  4. The Complexity of Songs, by Donald E. Knuth, is about loops.

Unix Bibliography

The i5.nyu.edu Unix manual.

The source code for the examples in the Handouts.

O’Reilly has books about vi and vim.

C/C++

To go anywhere in the Unix world beyond this course, you need the language C. The classic C book is The C Programming Language, 2nd ed. by Brian W. Kernighan and Dennis M. Ritchie; Prentice-Hall, 1988; ISBN 0-13-110362-8. See the pipeline on p. iv.

The definitive C++ book is The C++ Programming Language, special edition by Bjarne Stroustrup; Addison-Wesley, 1997; ISBN 0-201-70073-5. But the Stroustrup book is hard to read, so you should also see my C++ book.

The best book about structured programming is The Elements of Programming Style, Second Edition by Brian W. Kernighan and P. J. Plauger; McGraw-Hill, 1978; ISBN 0-07-034207-5.

Scripting languages

The three people who created awk wrote a book about it: The AWK Programming Language by Alfred V. Aho, Brian W. Kernighan, and Peter J. Weinberger; Addison-Wesley, 1988; ISBN 0-201-07981-X. See also sed & awk, Second Edition by Dale Dougherty & Arnold Robbins; O’Reilly & Associates, Inc, 1997; ISBN 1-56592-225-5.

The Perl language combines sed, awkawk, C, and the shell for system administration. Programming perl, 3rd ed. by Larry Wall, Tom Christiansen, and Jon Orwant; O’Reilly & Associates, 2000; ISBN 0-596-00027-8.

The “Tool Command Language” Tcl was invented so that you won’t need to invent new languages. The extended form Tk is for building GUI interfaces. Tcl and the Tk Toolkit by John K. Ousterhout; Addison-Wesley, 1994; ISBN 0-201-63337-X. Another extended form is the language Expect. Exploring Expect: A Tcl-based Toolkit for Automating Interactive Programs by Don Libes; O’Reilly & Associates, 1994; ISBN 1-56592-090-2

Web and HTML

Client-side touch-sensitive imagemaps, like the class photo.

To find out what teaching Unix is like, see The Education of Hyman Kaplan by Leonard Q. Ross (Leo Calvin Rosten).

Resources at NYU

Call the Help Center at (212) 998-3333, the Accounts Office at (212) 998-3035, read the ITS documentation, send mail to comment@nyu.edu.

System administration and kernel (outside the scope of this course)

UNIX System Administration Handbook, 3rd ed. by Evi Nemeth, Garth Snyder, Scott Seebass, and Trent R. Hein; Prentice-Hall, 2001; ISBN 0-13-020601-6.

You don’t need to know the kernel to use Unix. But if you want to see how it works, the most accessible treatment is Lions’ Commentary on UNIX 6th Edition with Source Code by John Lions; Annabooks, 1997; ISBN 1-57398-013-7. It shows what the kernel looked like in 1976 when it was less than 10,000 lines long. Douglas Comer’s XINU books (Prentice Hall) contain a miniature Unix-like operating system. And any book by Andrew S. Tanenbaum is good.

Instructor

Mark Meretzky teaches at the Information Technology department of the School of Continuing and Professional Studies of New York University.

List the students

Images

  1. Summer 2012 Section 1 (Tuesday) touch sensitive class photo
  2. Fall 2010 Section 1 (Tuesday) touch sensitive class photo
  3. Summer 2010 Section 1 (Tuesday) touch sensitive class photo
  4. Spring 2010 Section 1 (Tuesday) touch sensitive class photo
  5. Fall 2009 Section 1 (Tuesday) touch sensitive class photo
  6. Summer 2009 Section 1 (Tuesday) touch sensitive class photo
  7. Spring 2009 Section 1 (Tuesday) touch sensitive class photo
  8. Fall 2008 Section 1 (Tuesday) touch sensitive class photo
  9. Summer 2008 Section 1 (Tuesday) touch sensitive class photo
  10. Spring 2008 Section 1 (Tuesday) touch sensitive class photo
  11. Fall 2007 Section 1 (Tuesday) touch sensitive class photo
  12. Summer 2007 Section 1 (Tuesday/Thursday) touch sensitive class photo
  13. Spring 2007 Section 1 (Tuesday) touch sensitive class photo
  14. Fall 2006 Section 1 (Tuesday) touch sensitive class photo
  15. Summer 2006 Section 1 (Tuesday/Thursday) touch sensitive class photo
  16. Spring 2006 Section 1 (Tuesday) touch sensitive class photo
  17. Fall 2005 Section 1 (Tuesday) touch sensitive class photo
  18. Summer 2005 Section 1 (Tuesday) touch sensitive class photo
  19. Spring 2005 Section 1 (Tuesday) touch sensitive class photo
  20. Fall 2004 Section 1 (Tuesday) touch sensitive class photo
  21. Summer 2004 Section 1 (Tuesday) touch sensitive class photo
  22. Spring 2004 Section 1 (Tuesday) touch sensitive class photo
  23. Fall 2003 Section 1 (Tuesday) touch sensitive class photo
  24. Summer 2003 Section 1 (Tuesday) touch sensitive class photo
  25. Spring 2003 Section 1 (Tuesday) touch sensitive class photo
  26. Fall 2002 Section 1 (Tuesday) touch sensitive class photo
  27. Summer 2002 Section 2 (Tuesday) touch sensitive class photo
  28. Spring 2002 Section 2 (Tuesday) touch sensitive class photo
  29. Fall 2001 Section 2 (Tuesday) touch sensitive class photo
  30. Summer 2001 Section 2 (Tuesday) touch sensitive class photo
  31. Spring 2001 Section 2 (Tuesday) touch sensitive class photo
  32. Fall 2000 Section 2 (Tuesday) touch sensitive class photo
  33. Summer 2000 Section 1 (Monday) and Section 2 (Wednesday) touch sensitive class photos
  34. Spring 2000 Section 1 (Wednesday) and Section 2 (Tuesday) touch sensitive class photos
  35. Fall 1999 Section 2 (Tuesday) touch sensitive class photo
  36. Summer 1999 Section 1 (Wednesday) touch sensitive class photo
  37. Spring 1999 Section 1 (Wednesday) touch sensitive class photo
  38. Fall 1998 Section 1 (Wednesday) touch sensitive class photo
  39. Dilbert cartoons about Unix:
    1. November 9, 1993: “If the company nurse drops by, tell her I said “never mind.’”
    2. June 24, 1995: “You’re one of those condescending Unix computer users!”
  40. Gary Larson’s Far Side cartoon What we say to dogs.
  41. John Tenniel’s illustration of the Cheshire Cat in Alice in Wonderland.
  42. Skrik (The Scream) by the Norwegian artist Edvard Munch (1863–1944) is on the cover of The UNIX-HATERS Handbook by Simson Garfinkel, Daniel Weise, and Steven Strassmann; IDG Books, 1994; ISBN 1-56884-203-1.

Oldest Surviving Unix

Go to the The Computer History Simulation Project. Download the zip file containing the windows executables for all the SIMH simulators. Extract the executable file pdp11.exe.

Under “Software Kits to run on SIMH”, download PDP-11 UNIX V5 and extract the file unix_v5_rk.dsk. (The Interdata Unix V6 and V7 systems are particularly interesting as they represent the first ports of Unix written in C to a processor other than the PDP-11. In fact, they were done by a university team in Australia in parallel with a similar effort in Bell Labs. The Aussies finished first, despite having to build a cross compiler themselves and having to transport tapes by car between widely separated computers.)

The short summary documentation at http://simh.trailing-edge.com/pdf/simh_swre.pdf will tell you the magic incantations to load and run the operating systems.

sim> set cpu u18
Disabling XQ
sim> att rk0 unix_v5_rk.dsk
sim> boot rk
@unix

;login: root
#ls -l
control-d to logout

If you are adventurous, try going to the PDP-11 Unix Preservation Society page (http://minnie.tuhs.org/PUPS). With a little bit of hunting around, you can find 2.9 and 2.11 BSD in its archves at http://mirror.cc.vt.edu/pub/projects/Ancient_Unix/PDP-11/Distributions/. Research distributions and DEC Ultrix can also be had there. You will have to do a small amount of work to reformat the tape images into ones that will load in the emulators, but once you do, you can have the experience of loading a PDP-11 system from a distribution tape.

Movies that mention Unix

  1. Wayne’s World 2 (1993): “That’s a UNIX book…cool.”
  2. Jurassic Park (1993): “It’s a UNIX system! I know this!”
  3. Matrix Reloaded (2003) has nmap.

Links

  1. the i5.nyu.edu home page (no big deal)
  2. Languages:
  3. Versions of Unix:
  4. New York University
  5. List of the titles of the O’Reilly books.
  6. i5 uses the Apache web server.
  7. World Wide Web browsers
  8. the World Wide Web Consortium
  9. Philip and Alex’s Guide to Web Publishing by Philip Greenspun has its examples in Tcl, not Perl. Paperback, 608 pages (April 1999). Morgan Kaufman Publishers; ISBN: 1-55860-534-7.
  10. InterNIC: Network Information Center