CSC 101 Lab Notes and Exercises Week 1

CSC 101 Lab Notes and Exercises Week 1
Getting Started in the CSL Labs


Overview

The purpose of this week's lab is to familiarize you with the basic operation of the CSL (Computer Science Lab) computers and to introduce fundamental concepts of the UNIX operating system.

Exercise 0: Establishing a Central UNIX Account

If you do not already have an account on the campus central UNIX system, named "polylog1", you will need to establish one. This will be done as part of Exercise 1, if necessary.

Exercise 1: Logging on to Windows NT and the Central UNIX Computer

The following steps take you through the procedures of powering on the PC (if necessary), logging in to Windows NT, logging in to the central campus UNIX computer, logging out from the center UNIX computer, logging out from Windows NT, and powering off the PC (if necessary).


  1. Powering on the PC (if it is not already on)
    1. If the green power light is not already on, press the square or rectangular power button on the PC computer box, which is located beside or underneath the computer monitor.
    2. If the green power light is not already on, press the power button on the display monitor.
    3. After the PC goes through a self-test (which may be up to 30 seconds on some machines), select the default version of Windows NT 4.0 (not the VGA version). You can select by pressing spacebar or else just wait a few seconds and the default version will be selected automatically.
    4. Wait for the window that says "Press Ctrl + Alt + Delete to log on".
  2. Logging in to Windows NT 4.0
    1. Press the Ctrl, Alt and Delete keys simultaneously. Type the following user name, password, and domain name in the login window (click the Left mouse button or press Tab key to advance to next item to be typed):
      1. if you're in room 14-257: username = s255, password = s255, domain = CSL2
      2. if you're in room 14-303: username = s303, password = s303, domain = CSL3
      Note that the username and domain are normally already typed in, so that all you normally need to type yourself is the password.
    2. Click Login with Left mouse button.
  3. Making a terminal connection to UNIX using QVT/Term
    1. Move the Windows mouse cursor to the toolbar icon that looks like a small computer terminal.
      1. In room 14-257 lab, the Windows toolbar is along the right side of the screen and the terminal icon is the thirteenth one from the top in the toolbar.
      2. In room 14-303 lab, the Windows toolbar is along the bottom of the screen and the terminal icon is the seventh one from the left in the toolbar.
    2. Click the Left mouse button on the terminal icon; this will run the QVT/Term program.
    3. When the QVT/Term window opens:
      1. Click Left mouse button on File (left item of menu bar).
      2. Click the Left mouse button on Open.
      3. Click on polylog1 to connect to HP-UNIX (central campus UNIX).
      4. If the polylog1 name is not in the menu list, type the name in the Host Name: field. You can use the backspace key or click the Left mouse button to highlight then type over any name already in the Host Name: field. Note that you can connect to any computer on campus or the Internet by typing the hostname or complete host domain name for the Internet (e.g., hairball.ecst.csuchico.edu)
      5. Press the Enter (or return) key or else click Left mouse button on Ok.
      6. Follow the UNIX login procedure by entering your polylog1 account name and password.
      7. If you do not have a campus central UNIX account, type "new" after the login: prompt, and follow the instructions at gopher://gopher.calpoly.edu:70/hh/computing_at_CP/Documentation/userguides/aix/aix10701 to set up your new account.
      8. If the connection fails at any point, check for typing errors and try again.
    4. QVT/Term features include the following:
      1. The window may be resized to whatever size you wish, including full screen.
      2. The font size and type may be reset. Use the Font menu or toolbar icon.
      3. Screen colors may be reset. Use the Colors menu or toolbar icon.
      4. The scroll bars can be used, except when running a UNIX text editor; more on this in next week's lab.
    5. You can download QVT/Term for use on your home computer, or use any other comparable terminal emulation or "telnet" program at home. Information on QVT/Term downloading is available at the campus computing help desk, in person in the basement of building 14, or online at http://www.helpdesk.calpoly.edu/html/software.htm If you need assistance downloading an at-home copy of QVT/Term for CSC 101, we can help you out during the first or second week of lab.
  4. Terminating the UNIX Connection
    1. Logout from UNIX, using the logout or exit command.
    2. You may now Connect to another UNIX machine following the procedures above.
    3. When you're finished using QVT/Term, click the Left mouse button on the Windows Close button (the small box with "X" in upper right corner of window). Alternately, you can click the Left mouse button in File menu item, then click the Left mouse on the Exit menu item.
  5. Logging out from Windows NT
    1. Click the Left mouse button on Start on the task bar at bottom left of screen.
    2. Move the mouse pointer to Shutdown (the bottom menu item).
    3. Click the Left mouse button on Restart in the "What do want the computer to do?" window (room 303) or on Close all programs and log on as a different user? in the "Are you sure you want to?" window (room 257). In either case, the desired choice is the default, so it will normally already be selected.
    4. Click the Left mouse button on OK (room 303) or Yes (room 257), or else press the Enter key.
    5. An alternate short cut to the preceding four steps is as follows:
      1. Press the Ctrl, Alt, and Delete keys simultaneously.
      2. Left click on Logoff (you can also use tab key to move to this selection).
      3. Left click on OK or press the Enter key.
  6. Shutting down and powering off the PC
    1. You should NOT do this unless you are the last person at night to use the PC.
    2. If you are the last person at night, follow the same procedure as above under "Logging out from Windows", except choose "Shutdown" in the selection window.
    3. The computer will either power off automatically, or display a window with the message It is now safe to turn off your computer.
    4. If the It is now safe ... message appears, press the PC and monitor power buttons to turn them off.

Exercise 2: Bringing up the CSC 101 Web Page

  1. Click on the Netscape program icon on the Windows NT desktop.
  2. Type the following URL in the Location: area:
    http://www.csc.calpoly.edu/~gfisher/classes/101
    
  3. Browse this page and the other pages it links to.

Exercise 3: Familiarization with Basic UNIX Commands

Using the Hahn book and UNIX Guide, explore the following UNIX commands and features while logged on to the polylog1 computer.

  1. login, logout, passwd
    learn how to start and stop a session and change your password
  2. policy
    learn the Cal Poly UNIX user policies. Type this command and then explore the various choices (use keyboard arrow and carriage return keys)
  3. Shell programs (csh and tcsh)
    learn to use shell commands, and learn to change your default shell to tcsh
  4. Shell control characters for editing your command line: ^C, ^H, ^W, ^U
    learn how to kill (stop or abort) a command (program) and how to correct typing mistakes
  5. Basic syntax (format) of a Unix command:

    command or program name, followed by
    options or flags [optional], followed by
    argument(s) [optional]
    
    Note: < and > around a word below, e.g., <command>
    or <filename>, means that some other word should be
    substituted for the generic word within the <>, but the angle brackets
    should not be typed.  Square brackets around a generic word, e.g., [
    <flag> ] means that the word inside the brackets is optional,
    but the brackets should not be typed.
    
    
    E.g., in the command
    
    % ls -F ~gfisher/classes/101/labs
    the <command> value isls, the <flag> value is -F, and the <argument> value is~gfisher/classes/101/labs
    
    The ls command can also be used without the optional values as in
    
    % ls ~gfisher/classes/101/labs
    % ls -F
    % ls
  6. The man (manual pages) command
    learn how to look up the description of a Unix command online:
    % man <name-of-a-Unix- command>
    % man passwd
    % man 1 man
  7. Typing a file (display on computer screen)
    cat <filename> [ <another-filename>... ]
    more <filename>
  8. Directories and files (directories are like MacIntosh folders)
    learn the following:
    1. how to type a filename or directory name (a.k.a. pathname),
    2. hierarchical naming, e.g., absolute and relative "pathnames"
  9. An absolute path looks like this (no spaces between names and /'s):
    /<dir1>/<dir2>/ ... /<dirN>/<filename>
    /home/b1a/gfisher/101/labs/week1.txt
  10. A relative path looks like this:
    week1.txt
    ../week1.txt
    ../../week1.txt
  11. Using the tilde ('~') character with a login name, as in
    ~gfisher/classes/101/labs/week1.txt
  12. pwd
  13. mkdir and rmdir
    Learn how to create a new directory and how to remove (delete) a directory
    e.g., % mkdir csc101
    e.g., % rmdir csc101
  14. cd or chdir
    Learn how to change from one working directory to another:
    e.g., % cd <dirname>
    e.g., % cd (with no argument)
    e.g., % cd <dirname> (using relative and absolute pathnames)
  15. Listing file names:
    % ls [ <options>] [ <filename> ... | ... ]
    learn the following option flags: -a, -l, -F, -t
    e.g., % ls -a
    e.g., % ls -F ~gfisher
    e.g., % ls -lt csc101
  16. Copy, remove (delete) and move (rename) a file (not a directory)
    % cp [ <options> ] <copy-from-filename>
    % rm [ <options> ] <filename-to-remove>
    % mv [ <options> ] <old-filename> <new- filename>
    Warning: Beware of destroying files. cp and mv will write over the <copy-to-filename> or <new- filename> if it already exists. For safety, use the -i (interactive) option for all 3 cmds.
    % cp -i <copy-from- filename> <copy-to-filename>
    % rm -i <filename-to-remove>
    % mv -i <old-filename> <new-filename>
  17. Filenames are case sensitive:
    CSC101, Csc101, csc101 are each unique names!
  18. Using "dot" in filenames for extensions and parts of a name:
    prog1, prog1.C, prog2.C++, assign1.txt, 101.p2.test.C
  19. Pathname "wildcards": * and ? learn to shortcut typing full pathnames
    e.g., CSC*, *01, CSC?01, CSC10?, *CSC*, *
    e.g., % ls *.txt
    e.g., % ls ~gfisher/101/lab/*.txt
  20. Learn to recognize when you have made a typo that causes Unix to give an error message
    e.g., % LS 101
    LS: command not found
    e.g., % ls 119
    ls: 0653-341 The file 119 does not exist.
  21. Reading and sending mail:
    You are required to learn one (or more) of these Unix mail programs:
    1. elm, pine, or mail
    2. Refer to Hahn's Student Guide to Unix and Cal Poly's Unix User Guide - Introduction to UNIX
  22. Text editors: emacs, vi Learn what each one of these programs is (use of a text editor will be covered in the next lab activity)
    1. Refer to Hahn's Student Guide to Unix and Cal Poly's Unix User Guide - Introduction to UNIX
    2. NOTE: Do not waste your time learning pico. It is too limited to be useful in CSC 101.
  23. Some other useful commands:
    1. cal and date
    2. who and finger
    3. head <filename> and tail <filename>
    4. grep [-i] <string> <filename>
    5. wc <filename>
    6. history
    7. spell

Exercise 4: Establishing a CSC 101 Class Directory

Using the UNIX commands you learned in Exercise 2, perform the following steps:

  1. Make a directory under your home directory named "csc101" (use the mkdir command).
  2. Change the permissions on the directory so that it is readable only to you (use the chmod command).
  3. Make a subdirectory named "examples" under your new csc101 directory (use the cd and mkdir commands).
  4. Copy the file from ~gfisher/classes/101/labs/example1 into your csc101/examples directory (use the cp command; for convenience, use the tab key when typing the long pathname)
  5. Run the program and provide the input that it requests (run the program by typing its name, example1, followed by the Enter key).
The example1 program you just copied and ran is a slightly modified version of the C++ program for testing if a number is positive, which was discussed in the first week's lecture notes.

index | lectures | labs | handouts | assignments | solutions | grades | help