CSC 101 / CPE 101:
Fundamentals of Computer Science 1

Fall 2000
(Sections 04 & 08 only)


Using QVT/term to Login to your Unix account

(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.

  1. Launch the QVT-term application, via any one of these methods:
  2. In the QVTterm window

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.

  1. % mkdir directoryName
    Make a new directory (folder). Example,
    % mkdir csc101
  2. % cd directoryName
    Change directory(folder). This sets your "current", or "working", directory. Example,
    % cd csc101

    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

  3. % ls
    List names of files in your current directory (similar to the DOS command "dir").

    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...)

  4. % cp source-filename destination-filename
    Copy a file. Example,
    % cp exercise1.java exercise1.sav.java

  5. % mv old-filename new-filename
    Rename a file (UNIX calls it move). Example,
    % mv exercise1.java exercise1.old.java

  6. % rm filename
    Remove (delete) a file. Example,
    % rm -i exercise1.old.java
    Using -i is an option flag that means ask ("inquire") the user to confirm whether he/she really wants to remove the file before UNIX actually removes it. NOTE: UNIX has no "trash bin", so files accidently deleted cannot be recovered!!!

  7. % cat filename
    Display (concatenate) a file on the terminal screen. Example,
    % cat exercise1.java

  8. % more filename
    Display a file on the terminal screen with page scrolling. Example,
    % more exercise1.java
    For files longer than one screenful this command shows one page, waits for the user to press the space bar, and then displays the next page. There are a few alternative commands that produce a similar page-at-a-time display, e.g., less and pg.

  9. Run a command (program). Type the name of the program, optionally followed by the program's "arguments". Examples,
    % handin
    % javac Hello.java

    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

  10. While you are logged into your Unix account, run the following commands.
    Then answer the questions below.

    % 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:

  1. What are the names of the files in the directory ~lhitchne/CSC101/src
  2. What are the names and sizes (# of bytes) of the files in the directory ~lhitchne/CSC101/src/Lab1
  3. How many directories are contained in the directory ~lhitchne/CSC101/src/examples
  4. What error message was displayed by Unix when you typed % more addition
  5. What is the size (# of bytes) of the file ~lhitchne/CSC101/src/examples/chap02/Addition.java
  6. What was displayed on the screen when you ran % java Addition
  7. Document each of the above in your lab notebook.

Copyright © 2000 by Carol Scheftic. All rights reserved. Used by permission.
(Thanks to Professor Lew Hitchner for documenting this process.)
Requests to reuse information from this page should be directed to Carol Scheftic.
Page created 29 September 2000; last updated 23 June 2001.