ENG 101: Inlab #1 -- Winter 2005

 Name: ___________________________________  Uname: __________  Lab section: ____________ 

This is the first in-lab assignment for Engineering 101. You will be expected to turn this in to your lab instructor at the start of your next lab period. It is worth approximately 0.5% of your course grade. Recall that you will be allowed to drop two in-lab assignments. The first page of this write-up must be stapled to the front of the printout you hand in for this assignment. The assignment is graded out of 30 points.

There are a large number of links from this page to other sites. You may find it helpful to read this document on-line.


The computers in the 101 lab use Linux as their OS. Specifically a Red Hat produced flavor of Linux. It has a specific desktop environment and window manager as well as lots of other stuff. Unlike other OSes (say Windows and OS X) the look and feel of Linux can differ hugely depending upon different software choices. For this in-lab we will assume you can get a terminal window open. After that we will walk you through a few different tools. You need not use these tools during the rest of the semester, but you will have to use something like them (so I'll be using "tcsh" as a shell, you are welcome to use something else like "bash" if that is what you are used to.)

The rest of this document will use the terms Unix and Linux interchangebly. If this offends you, look on the bright side: you probably know enough this will be a really short assignment.

A warning

Usability is an interesting concept. As an engineer you will learn that some tools are easy to learn, but tend to have limited depth (think Checkers) while other tools have a great deal of depth, but take significant initial effort to even understand (Chess or Bridge come to mind). A great tool is both easy to learn and has significant depth (Go, or perhaps Halo for you more modern types).

Sadly, designing something as easy yet deep as "Go" requires a skill not often found. And certainly not found in the folks who designed the tools we will be using in this class. This means you will be learning a bunch of very powerful but hard-to-use tools. For the CS majors, that is actually a good thing; later they will need the power. For the rest of you it is certainly sub-optimal, but the truth is, these are the tools engineers end up using to program. Microsoft's "Visual Studio" is a lot more pretty and easy to use until you actually try to do something real with it. Then it goes the way of most GUIs: without someone acting as an administator for the system things get messed-up in a hurry. (and you wonder how CS majors can find jobs).

So be warned. The tools here are confusing yet powerful. They were designed by experts to be used by experts, or at least people who are willing to learn a lot in order to become proficient. Thus expect a lot of frustration in the early going (say the first three or four years). I (Prof. Brehob) consider myself an expert with many of these tools, but I still learn things about them and say "Wow, that's handy, wish I'd known about that a few years ago."

Using the terminal

In general the command-line interface is the launching pad of the most relevant applications you will be using. It is also how you will navigate the file system. Let's start by typing "tcsh" which will bring you into the tcsh shell.

Once in the tcsh shell type "mkdir 101" (note I'm asking you to type what is in the quotes, not the quotes themselves. Also I'm expecting you to hit return after you type what I've put in quotes.) You have now created a directory called "101". Now type "cd 101". Then "touch foo" and finally "ls". You should get a response of "foo" on a line by itself. What just happened is you created a directory named "101", changed directory into it (the cd command) and created a blank file called foo. The ls command gave you a listing of the directory contents (which consisted only of the file foo.)

Now "cd /tmp". /tmp is a shared directory that everyone can use. Use of space here doesn't count against any quota, but it also can go away with no notice (mainly on reboot) so don't plan on keeping anything important here. Now type "cd -" then "ls". If all has gone well you should be back in your 101 directory. Now type "cd" then "ls". The "cd -" brings you back to your last directory while "cd" brings you to your home directory.

Some other commands:

Last bit. When selecting text with the mouse in the terminal, that text is automatically copied to the copy buffer. In fact this is true for most Unix programs. You may find that helpful when working on the rest of this in-lab.

The editor

There are lots of editors out there. (Emacs and its variants (mainly xemacs) and vi and its variants (mainly vim/gvim) are the two most popular. They also are rather complex (read "chess-like"). A simple editor (checkers-like) is nedit. Like checkers, nedit has some significant depth to it, but it just isn't as nice to use one you get going as either emacs or vi. None-the-less, it is what we will start you off with. If you are going to be a CS major or otherwise expect to be writing lots of code, I strongly recommend you learn emacs or vim/gvim. Both work just fine in Windows, Linux, OS X, and pretty much everything else and a simple web search should turn up the download sites (the software is free). This is a decent vi tutorial.

Nedit is pretty nice and simple. Just type "nedit &" from the terminal. (That & tells the shell to launch the application but don't wait for the application to finish. Technically it was just put into the background.) You may need to move the windows around so that you can see all of both the terminal and the nedit window. You should be able to type in the nedit window, use the arrow keys to move around etc. Further, the menu system and control-key combinations should be pretty similar to editors you may have used in Windows.

Now at the top of the nedit document type your name and uname and hit enter. Now select the text of this paragraph (you are reading this on-line right?) using the mouse. Put the mouse under the line with your name and press the middle-mouse button. This paragraph should appear. Now, using the menu system, save this file in your 101 directory as "inlab1.txt".

Now hit enter a couple of times (providing a gap between the paragraph and the end of the document.) During this in lab I strongly suggest you save your work often. Label each of your answers by their question numbers in the rest of this document. So after you answer questions 1 and 2 you would get something like this:


First Name, Last name, uname
Now at the top of the nedit document type your name and uname and hit enter.
Now select the text of this paragraph (you are reading this on-line right?)
using the mouse.  Put the mouse under the line with your name and press the
middle-mouse button.  This paragraph should appear.  Now, using the menu
system, save this file in your 101 directory as "inlab1.txt".


#1: XXXXXX
#2: 
    YYYYYY
    YYYYYY
    

The complier

Using a web browser, go to the course homework page. Under in-lab 1 there is a file called "Hello.cc". Save it to your 101 directory as Hello.cc. In the terminal type "cat Hello.cc". That is the contents of the file Hello.cc. Be sure not to cat executable files. That can really mess things up.

Type "g++ Hello.cc". There should be a pause but then the prompt should return with no message.

Now remove the a.out file.

What you have just done is run the C++ complier. It complied the code and created an executable. Also, you just used a "command-line option". The -o flag tells the complier what to name the executable that it generates. Most Unix commands (including ls, cp, and the like) have command-line options.

Those unreadable man pages

The man pages are part of the on-line documentation for Unix/Linux. They are written for those who know a lot about Unix to begin with. For everyone else they are mostly just annoying. None-the-less, from time to time it will be worth your time to read these. You will have hit a computer Zen point when not only do the man pages start to make perfect sense, but you start to believe they are just about perfect.

Type "man man". This is the manual page for the "man" command. Figure out how to scroll up and down. Notice that you get a short description (called "name" of course) a synopsis of the format of the command (it tells you what command line options you can add) and a longer description (called Description!). After that you get a list of the command-line options (called Options) and then you start getting lots of other details about the program.

Exit the man entry for man (try the letter q). Now pull up the man pages for ls. Try to figure out what the "-a" flag does.

Back to the shell

Type "ls f*TAB*" where *TAB* is the tab key. What happens?

Printing

Use the command lpr to print. You should use the man page for lpr to figure out how to print to the printer in the lab. Now save this file (which you've been doing all along right?) and print it. Staple it to the first page of this document. You're done!

Misc.

If you just have to do more stuff, sit down and learn how to use either emacs or vi. Or you can try to figure out where the website "slashdot.org" got its name from. If all else fails, do the reading from the text.