This tutorial covers:
Login and type register comp212, which will create your own comp212 subdirectory. For this tutorial, further create a tutorials/01 directory, which will contain any (other) files you're asked to create. You will be expected to keep all your comp212 work in this directory. Do NOT modify the permissions on this directory. Doing so may result in 0's on some assignments.
Using man ls, read about a file's permissions. If you own a file with permissions -rw-r--r--, can your friends read it? Can they write to it? Who can get to your comp212 directory?
Read what the following flags to ls do: -l, -A, -F, -t, -d. What are the permissions for your newly-created personal ~/comp212/?
Use cp -p to copy the file silly.txt from comp212's tutorials/ to your directory while still preserving its august timestamp. Verify to yourself, that your copy doesn't have a newer date.
Use chmod to make your copy of silly.txt file readable by yourself only.
Using alias, how would you abbreviate ll to be shorthand for ls -FlAt? (You can use an abbreviation other than ll if you like.)
Make a symbolic link (ln -s) to this tutorial file in your own directory, called unixtutorial.html. What is an advantage and a disadvantage to symbolic links?
If you haven't already, use chsh to change your shell to tcsh (or, anything besides csh or sh). Linux users including myself may be used to bash. This is a one-time task. See /etc/shells for the full pathname of valid shells. If curious, you can see ~ian/.tcshrc for some tcsh-specific customizations.
In your new shell, what key do you press to repeat previous commands?
In your new shell, what key do you press for filename completion?
Does this same key work in emacs, for filename completion?
An unfortunate fact of life is that programs crash. In Windows, you get the Blue Screen of Death and you usually have to reboot or something. That sucks. (You will notice, many of the labbies have a slight bias against Microsloth. Dr. Nguyen is like the ONLY person in the entire CS department that loves M$.) Anyways, in Unix, you have the option to close these programs without having to reboot or log back in. The command I'm talking about is kill. To use this very powerful command, the computer needs to know just what it is exactly you want dead. This is accomplished by something known as a PID (process identification) number. In Unix, anything that "runs" has a unique number assigned to them. You can find out PIDs using the program top or ps. Once you have the PID of the program you want stopped, you just type kill "PID" ("PID" being the PID of the program you want to kill).
Ok, another cool thing. Do you know how to copy and paste in unix? Well, in case you didn't, try highlighting some text by using the left mouse button. What you just did is the same as the Copy function in Windoze. Now, go to where you want to paste the text and click the Middle button on the mouse. It should automatically paste what was highlighted. This little feature should aid you when you start programming.
To do: Use >> to append the output of cal 1752 to your answer file. (See the man page to see why the 1752's calendar is strange.
If much of this material is new to you, don't worry. This tutorial covers much more than you need to know for the course. Of course, if you don't understand something, it is up to you to come to us for help. For assistance, you can:
read man pages,
talk with your friends,
gather a few co-perplexed friends and schedule a time with a labby,
see Owlnet handouts,
There isn't as much to say about emacs as there is about Unix. I'll just say that it is the preferred editor of choice for advanced CS classes. Of course, you are allowed to use any editor you want, but most of us labbies are most familiar with emacs. Emacs has evolved a lot since it's beginnings. Many people say it's a bloated program. It does too much. In the spirit of recursive acronyms, emacs was said to mean "Emacs Makes A Computer Slow." Now, though, emacs works fine on modern machines. It is an amazingly configurable program. In fact, you can even read your email or newsgroup postings and more using just emacs. This part of the tutorial will just cover a few basic things. If you want to learn more, check out the owlnet Unix help pages on emacs.
Now, the most confusing thing for emacs newbies is understanding the notation used for commands. If you check out the Emacs reference card You will see commands like:
What this notation means is:
Press Control-x and then press Control-f (which lets you find a file)
Press Control-x and then press Control-c (which exits emacs)
Press Meta-x (the Meta key is usually the Esc key)
Some other good keyboard commands include:
C-x C-s (to save)
C-g (to cancel whatever command you're in the middle of)
M-c (the comp212 emacs configuration sets this key as a shortcut to compile your current program)
Emacs isn't perfect though. From personal experience, it can freeze on you sometimes for no apparent reason. Therefore, I suggest you save frequently.
Another cool thing is that for commands, there is also tab-completion. Try opening a file using C-x C-f. If you just type the first couple letters of a file you want and press tab, emacs will try to complete the name of your file when you press Tab. This is good because as computer scientists, we are lazy.
Emacs also has an auto-save feature. If you notice some files that show up in your directory starting with a #, it's one of those files emacs saved for you. In the event of a crash or any other situation where you were forced to exit emacs without saving your work. Emacs has an option to recover the last auto-saved version. Pressing M-x and then typing recover-file will help you get that file back. There are a tremendous number of commands that can follow a M-x. If you forget exactly the one you want, don't forget the tab completion to help you figure out which one you're looking for.
Another feature of emacs lets you change the type and size of fonts and much more. Try holding down the Ctrl key and pressing the left mouse button while emacs has the mouse focus. Now, try holding down shift and the left button. I'll leave it to you to play around with it.
StructureBuilder (SB) is a tool to create UML class diagrams and automatically generating Java stub codes. It also can reverse engineer Java source/byte code to produce the UML corresponding UML diagrams. In this lab tutotial, we will use SB to illustrate the design of our Pizza program. Perform the following steps to create the UML diagrams for the Pizza design, as shown in the 01/21/99 lecture
Go to your directory ~/comp212/tutorials/01 (which you just created). You
should have the files PizzaClient.java, Pizza.java, AShape.java,
Rectangle.java in this directory (which can be
checked by the command
ls -al, which lists files: all of them (-a),
in the long format (-l).
First compile the file
PizzaClient.java by giving the command:
Now you can actually start executing the program with the command:
You'll see an output that says something about which pizza is a better deal.
There is another more convenient way to run the edit-compile-debug cycle from inside the emacs editor. For an intro to emacs, you can see Owlnet's emacs intro, useful-commands summary, or reference card (html or ps).
Load up the file PizzaClient.java in an Emacs buffer by the command:
C-x C-f PizzaClient.java RET
From within Emacs, give the following command:
or simple type the keystrokes
In the minibuffer, Emacs will suggest to you the compile command to use. This should be
javac PizzaClient.java, as above. Simply press RET after this. The
compilation will begin and the details will be shown in a special Emacs buffer called *compilation*.
If there are any errors, they will appear in this buffer. As there are no errors in
*.java, the compilation should finish successfully and you should see a message like:
Compilation finished at .....
To run the program, now go to the Unix prompt and as before,
and you'll again see the familiar output again.
Warning: if you rename a file, ESC c may suggest the wrong file name. In that case you can edit the file name on the command line before typing RET.D. X. Nguyen, Jan 23, 2000. firstname.lastname@example.org