Fall 2000
(Sections 04 & 08 only) |
(These instructions were generously contributed by Prof. Lew Hitchner; I'll likely revise them eventually...)
Learn to login to UNIX with the QVT_term program.
QVT_term is a program that runs a login session on UNIX from the PC. It will make your Unix session appear similar to the DOS shell window in Windows/NT and it has several nice features. You may use any terminal program of your choice on your own PC, but if you'd like to download and use the same tools as we use in lab, you can get both WS_ftp and QVT_term from Cal Poly's software distribution site.
When you login to UNIX with QVT_term, you will type commands similar to those you type in a DOS window on a Windows PC. We will learn some basic UNIX commands during the next few weeks, but for now you can just use the ones explained here.
Learn some basic UNIX commands.
Read each of the following and try each one at least once or more. Both lab partners should login to your own UNIX account and practice these.
You must learn to use these so that you can "turnin" your lab and program work from now on.
You can also use other "pathnames", e.g. if you had created the directory "lab2" within the directory "csc101" and the directory "myFiles" within the directory "lab2" then you could use:
% cd csc101/lab2/myFiles
instead of
% cd csc101
% cd lab2
% cd myFiles
A shortcut to change back to your "home"
(login) directory is,
% cd
There are filename shortcuts for user's "home" directories. For your own home directory, the shortcut is ~ , e.g.,
% cd ~
changes to your home directory (same as the shortcut "cd").
% cd ~/public_html
changes to your public_html directory (if you have one) that may be contained within your home directory.
A shortcut to another user's home directory is just tilde followed by their user login, e.g.,
% cd ~buckalew/CSC101/src/Lab1
When these directories were first created, user buckalew had to type the following (assuming he starts in his home directory, ~buckalew):
% mkdir CSC101
% cd CSC101
% mkdir src
% cd src
% mkdir Lab1
The ls command has several options. Two very useful ones are,
% ls -l
long list of file names including detailed information, such as size in bytes, date and time of last modification, etc.
% ls -a
list names of ALL files, including "hidden" files (ones whose name begins with a "dot").
These options may be combined in any order, either as,
% ls -l -a
or,
% ls -la
You can list files in other directories without changing to that directory. Example,
% ls -l ~buckalew/CSC101/src/Lab1
(Sometimes you will get a message saying you don't have permission to do this. Permissions will be covered later on...)
HOWEVER, Unix assumes program names are names RELATIVE TO a particular directory: the directory in which you are currently working. This is called the "current working directory" and it can be displayed by typing the UNIX command (pwd means Print Working Directory)
% pwd
Thus, when the program to be run is not in your current working directory, you have to type the directory pathname instead of just the file name. Examples:
% /home/b1b/csc10104/handin csc10104
% /home/b2c/csc10108/handin csc10108
Or, you can use the filename shortcut,
% ~csc10104/handin csc10104
% ~csc10108/handin csc10108
Many Unix commands can be executed (run) without typing their full pathname because Unix "knows about" some built-in paths (directories). For example, you should be able to run the Java compiler and the Java execution program by typing,
% javac Hello.java
% java Hello
Because Unix knows that the files javac and java
are in the directory /opt/java/bin, this is equivalent
to typing,
% /opt/java/bin/javac Hello.java
% /opt/java/bin/java Hello
To find out in what directory a file exists, type the Unix command, which, e.g.,
% which javac
/opt/java/bin/javac
Here are a few interesting programs to run (try these!):
% who
% date
% lynx ns.calpoly.edu
% cd ~lhitchne/CSC101/src
% ls
% ls -l Lab1
% cd examples
% ls
% cd chap02
% more addition
% more Addition
% ls -l
% more Addition.java
% cp Addition.java ~/csc101/lab2
Note: ~ refers to your own home directory and this command assumes you have a directory named csc101 in your home directory and a directory named lab2 within your csc101 directory. If directories by those names do not exist, you should make new directories or use names of directories that do exist. Recall from Lab #1, you can create your own new directories with the Unix mkdir command, e.g.,
% mkdir csc101
% cd csc101
% mkdir lab2
% cd
% cd csc101/lab2 #
or whatever directory you used in place of csc101/lab2 above
% javac Addition.java
% java Addition
QUESTIONS TO ANSWER: