Lectures 6 through 8 of this course constitute the subcourse Regular Expressions INFO1-CE9960.
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.
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.
Please bring a cellphone to the first class to take the class photo.
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.
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.
.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.
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
.
.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.
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
Put an image file into your
public_html
directory,
and then display the image in your
index.html
file.
No class July 3rd.
`
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.
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
vi
s,
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.
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.
The i5.nyu.edu Unix manual.
The source code for the examples in the Handouts.
O’Reilly
has books about
vi
and
vim
.
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.
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
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).
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.
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.
nmap
.