Linux at Rancho Santiago College

Steve Moritsugu

Issue #45, January 1998

Linux is being used to teach Computer Science classes at a community college in Santa Ana, California.

Roughly twice a year, I find myself combing the Unix job ads in the LA Times. Luckily, this does not mean I am frequently unemployed. In fact, in addition to my full-time job integrating, supporting and teaching Unix, I am also a part-time instructor at Rancho Santiago, a community college in Santa Ana, California. For the first hour of the first class of every semester, the parking lots are a jungle, and students are struggling to find the right buildings and classrooms. I use this hour to discuss the recent Unix job ads and “buzz words”. I cover what students will learn in my class and what additional skills employers list most often in these ads. In January 97, employers most often wanted Unix plus C programming or Unix plus Windows NT (networking). Rarely do ads mention a specific Unix operating system type such as HP, Sun or Linux.

Unix Like a Car Radio?

I use Linux extensively in my classes. I also use the free version of SCO Unix. I teach a series of three full-semester Unix classes available at Rancho:

  1. CMPR 141: Unix Operating System

  2. CMPR 241: Unix System Administration

  3. CMPR 242: Advanced Unix Shell Scripts

In each of these classes, I give my car radio analogy. There are many different styles of car radios, each with a slightly different placement of knobs and controls; yet when most people get into a strange car, they can turn on the radio, adjust the volume, change the station and maybe set their favorite stations. In the same way, Unix on different computer platforms has variations in the basic commands, e.g., how you log off or how you display a file one page at a time. There is no need to become disoriented when you face a strange car radio, oops ... I mean when you face a new variant of Unix, especially if you are on the Internet, using TELNET to access one host or another. While Linux has peculiarities that you don't find on other flavors of Unix, it is not alone. Every Unix has some peculiarities. For me, the important issue is that Linux supports all the standard Unix commands and shell features.

Why Linux?

When I first started teaching at Rancho, my biggest problem was the fact that students had no access to Unix outside of my three-hour once-per-week class. The school has a computer lab, but none of the systems there had access to Unix. I considered several alternatives before deciding on Linux. There are packages that allow you to run Unix utilities under MS-DOS. I decided against using these, because the problems that arose were not really Unix issues, such as MS-DOS not supporting upper and lower case file names or Unix permissions. There was another flavor of Unix that could be loaded from floppy, but that company is no longer in business. The free version of SCO was not available at the time and, since it is only a 2-user version, it must be installed at each station which is difficult in a lab situation.

I also considered freeBSD. However, I eventually chose to use Linux in my classroom for the following reasons:

  • Linux acts like a standard version of Unix and the problems that arise are true Unix issues (not MS-DOS issues).

  • Linux has a large body of documentation and HOWTOs that allow me to customize the package as needed.

  • Linux licensing allows me to make the software freely available to students.

  • Linux evolves continuously, supporting new hardware as it becomes available.

  • Internet ISPs use Linux as e-mail and/or domain name servers.

  • Linux is strongly represented in the technical book stores under both the Unix and Internet categories.

  • There are a number of different Linux distributions, fostering healthy competition and adding value.

All of the above show that Linux is a thriving variant of Unix, worth studying in its own right, as well as a useful teaching tool.

On the other hand, I also warn my students that Linux is not yet fully accepted as a commercial grade of Unix by all employers. I also use the free SCO Unix in my classroom so that students can see variations in Unix side-by-side, and so they can list SCO Unix as well as Linux in their resumes.

Floppy-Based Linux

For my students, I have created a distribution of Linux which I call Floppy-Based Linux. It runs completely from floppy and never accesses the hard disk, yet it supports all the standard Unix commands and man pages. It can also use TELNET and FTP to access the Linux server running in the classroom and can print to network printers in the classroom and the computer lab. Of course, this is slower than running from hard disk, but it provides a number of advantages in my environment. My students are often computer neophytes. I need a bullet-proof environment where they can freely make mistakes. Thus, I ruled out any distributions that would require them to load software onto the hard disk, even the UMSDOS file system. I want my students to be able to work on Unix at home, at work or in the school computer lab since I believe that accessing Unix hands-on is essential to learning Unix. At the same time, I could not take a chance that a mistake on their part might alter or corrupt their home computer, work computer or lab computer.

My students can run Floppy-Based Linux on any PC with 8MB of RAM and a 3.5-inch floppy drive. The floppy diskettes are write-protected when in use, so they cannot be corrupted. The Linux kernel has been rebuilt, so that it has no drivers for IDE or SCSI hard disks to ensure that a student cannot alter the hard disk. At first, I started with the Slackware 3.0 boot diskettes and RAM disk, but I found that these are not in ELF format so I could not add some of the commands I wanted. Following the boot disk HOWTO, I created my own boot diskette and 3MB RAM disk. After loading the RAM disk, an rc script prompts the student to insert a “Supplement” diskette, which loads more files into the root file system in memory. Students then mount a “Utils” diskette which gives them access to many more Unix commands and man pages.

Students can use Floppy-Based Linux for homework assignments outside of the classroom. Inside the classroom, there are 18 Windows PCs, one Linux Server and one free SCO Unix system. Students bring up Floppy-Based Linux on the Windows PCs and then download new homework assignments from the Linux server using FTP. They also upload their completed homework to the Linux server. They can print to a network printer in the classroom. I have also used variants of Floppy-Based Linux to debug network problems and to make image backups of a Windows hard-disk partition using dd (device-to-device copy) “piped” to rsh (remote shell) to save the data on another system in the network or its tape drive. (Hard disk access was enabled in order to do this.)

Electronic Blackboard

I have taught Unix and networking seminars and training sessions nationwide. There is one teaching technique I use in these sessions and also in my classroom that I am asked about most frequently. I call it my “electronic blackboard”. It allows me to broadcast everything that appears on my station to all Unix stations in the room. Students can watch me enter commands, backspace, make corrections and use command-line editing to develop long, complicated pipe sequences in gradual steps. Instead of writing on a blackboard, I use vi to put any notes into a file. Students see the notes as I type them, as well as how I use vi, and at the end of class I can print the file as a handout. (It helps that I am a speedy typist.)

This broadcasting technique is scalable in that I can broadcast to one station as easily as to 200 or 500 stations. I can do this broadcasting using two simple Unix commands that are available on all flavors of Unix including Linux. No special software is required. Can you figure out how I do it? Here is the answer. At my station, I first run this command:

telnet localhost | tee /ttt

This gives me a new Unix login. All output and the echo of everything I type will now be saved in the file /ttt. (If you don't have networking set up, you can do the same thing using cu, or call up, and a loop-back cable between two serial ports.)

At each of the student stations, run this command:

tail -f /ttt

tail will run until aborted, reading every new keystroke added to file /ttt and displaying it on each student's screen. Now each screen perfectly reproduces what appears on my screen. I can also automate this by writing a script to start all the tail<\!s>-f commands at one time. Note: each student station must be set up to use the same TERM variable as I am using at my teaching station, since escape sequences and graphics will also be broadcast.

Advanced Regular Expression Lesson

In closing, I would like to leave you with a lesson that I teach in advanced regular expressions, which applies to Linux as well as other flavors of Unix. The rule is: “to simplify line-oriented regular expressions, drop unbounded or more wild cards.” This is analogous to simplifying unnecessarily complex fractions in mathematics. The simplified expression is more efficient to implement and easier to understand. I find that most students understand advanced regular expressions much better once they understand this rule.

In regular expressions there are two wild cards that I call “or more” wild cards, as shown in these two examples:

grep  'aa*bc'  file

Search for and display any lines in file that contain one or more instances of a's, then b, then c.

grep -E 'abc\{10,\}' file
Search for and display any lines in file which contain a, then b, then 10 or more instances of c.

Both of these “or more” wild cards are unbounded, because the “or more” wild card occurs either at the start or the end of the regular expression pattern.

Contains “or more”

Better Pattern

1. aa*bc

abc

2. abc\{10,\}

abc\{10\}

3. zaa*bc

zaa*bc (same)

4. abc\{10,\}$

abc\{10,\}$ (same)

In example #1 above, the “or more” wild card is unbounded, so leave it out. Searching for abc is more efficient and easier to understand than searching for aa*bc and results in the same lines being selected.

In example #2 above, the “or more” wild card is again unbounded, so leave out the comma. To prove that two regular expression patterns are equivalent, we need to show:

  1. They do select the same lines. In this case, any line that contains a then b then 10 or more c's also contains a then b then 10 c's.

  2. They avoid the same lines. In this case, any line that does not contain a then b then 10 or more c's also does not contain a then b then 10 c's.

In example #3 above, the “or more” is bounded on both sides, so you cannot ignore it. Looking for z, then one or more a's then b then c is different than looking for z then a then b then c.

In example #4 above, the “or more” is bounded on both sides, so you cannot ignore it. The $ sign indicates the 10 or more c's must occur at the end of the line, which is different than looking for exactly 10 c's at the end of the line.

The sed command is not line-oriented, hence this rule does not apply.

sed s/aa*bc//g file

This command instructs sed to delete any segment in file that consists of one or more a's, then b, then c.

Command to delete any segment which consists of a then b then c:

sed s/abc//g file

Since sed is not line oriented, do not drop unbounded “or more” wild cards.

Steve “Mor” Moritsugu (mori@dtrbus.com) is a senior software engineer at DTR Business Systems in Walnut, California. He is also the Unix instructor at Rancho Santiago College in Santa Ana, California.