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).
-
Powering on the PC (if it is not already on)
-
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.
-
If the green power light is not already on, press the power button on the
display monitor.
-
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.
-
Wait for the window that says "Press Ctrl + Alt + Delete to log on".
-
Logging in to Windows NT 4.0
-
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):
-
if you're in room 14-257: username = s255, password =
s255, domain = CSL2
-
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.
-
Click Login with Left mouse button.
-
Making a terminal connection to UNIX using QVT/Term
-
Move the Windows mouse cursor to the toolbar icon that looks like a small
computer terminal.
-
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.
-
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.
-
Click the Left mouse button on the terminal icon; this will run the QVT/Term
program.
-
When the QVT/Term window opens:
-
Click Left mouse button on File (left item of menu bar).
-
Click the Left mouse button on Open.
-
Click on polylog1 to connect to HP-UNIX (central campus UNIX).
-
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)
-
Press the Enter (or return) key or else click
Left mouse button on Ok.
-
Follow the UNIX login procedure by entering your polylog1 account name and
password.
-
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.
-
If the connection fails at any point, check for typing errors and try again.
-
QVT/Term features include the following:
-
The window may be resized to whatever size you wish, including full screen.
-
The font size and type may be reset. Use the Font menu or
toolbar icon.
-
Screen colors may be reset. Use the Colors menu or toolbar
icon.
-
The scroll bars can be used, except when running a UNIX text editor; more on
this in next week's lab.
-
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.
-
Terminating the UNIX Connection
-
Logout from UNIX, using the logout or exit
command.
-
You may now Connect to another UNIX machine following the
procedures above.
-
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.
-
Logging out from Windows NT
-
Click the Left mouse button on Start on the task bar at bottom
left of screen.
-
Move the mouse pointer to Shutdown (the bottom menu item).
-
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.
-
Click the Left mouse button on OK (room 303) or
Yes (room 257), or else press the Enter key.
-
An alternate short cut to the preceding four steps is as follows:
-
Press the Ctrl, Alt, and
Delete keys simultaneously.
-
Left click on Logoff (you can also use tab key to move to this
selection).
-
Left click on OK or press the Enter key.
-
Shutting down and powering off the PC
-
You should NOT do this unless you are the last person at night to use
the PC.
-
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.
-
The computer will either power off automatically, or display a window with the
message It is now safe to turn off your computer.
-
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
-
Click on the Netscape program icon on the Windows NT desktop.
-
Type the following URL in the Location: area:
http://www.csc.calpoly.edu/~gfisher/classes/101
-
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.
-
login, logout, passwd
learn how to start and stop a
session and change your password
-
policy
learn the Cal Poly UNIX user policies. Type this
command and then explore the various choices (use keyboard arrow and carriage
return keys)
-
Shell programs (csh and tcsh)
learn to
use shell commands, and learn to change your default shell to
tcsh
-
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
-
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
-
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
-
Typing a file (display on computer screen)
cat <filename> [
<another-filename>... ]
more <filename>
-
Directories and files (directories are like MacIntosh folders)
learn the
following:
-
how to type a filename or directory name (a.k.a. pathname),
-
hierarchical naming, e.g., absolute and relative "pathnames"
-
An absolute path looks like this (no spaces between names and /'s):
/<dir1>/<dir2>/ ...
/<dirN>/<filename>
/home/b1a/gfisher/101/labs/week1.txt
-
A relative path looks like this:
week1.txt
../week1.txt
../../week1.txt
-
Using the tilde ('~') character with a login name, as in
~gfisher/classes/101/labs/week1.txt
-
pwd
-
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
-
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)
-
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
-
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>
-
Filenames are case sensitive:
CSC101, Csc101, csc101 are each unique
names!
-
Using "dot" in filenames for extensions and parts of a name:
prog1,
prog1.C, prog2.C++, assign1.txt, 101.p2.test.C
-
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
-
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.
-
Reading and sending mail:
You are required to learn one
(or more) of these Unix mail programs:
-
elm, pine, or mail
-
Refer to Hahn's Student Guide to Unix and Cal Poly's
Unix User Guide - Introduction to UNIX
-
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)
-
Refer to Hahn's Student Guide to Unix and Cal Poly's
Unix User Guide - Introduction to UNIX
-
NOTE: Do not waste your time learning pico.
It is too limited to be useful in CSC 101.
-
Some other useful commands:
-
cal and date
-
who and finger
-
head <filename> and tail
<filename>
-
grep [-i] <string> <filename>
-
wc <filename>
-
history
-
spell
Exercise 4: Establishing a CSC 101 Class Directory
Using the UNIX commands you learned in Exercise 2, perform the following steps:
-
Make a directory under your home directory named "csc101" (use the
mkdir command).
-
Change the permissions on the directory so that it is readable only to you (use
the chmod command).
-
Make a subdirectory named "examples" under your new csc101 directory (use the
cd and mkdir commands).
-
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)
-
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