Computer
Survival
Guide

Table of Contents

 


Getting Started………………………………………….……3-6

 

Where are the ECT Computer Systems ………………………………………………….3

Accessing the ECT Computers Remotely (using PuTTY) ………………………………3

Getting and using PuTTY………………………………………………………………...3

 

The Joy of Unix………………………………………………6-11

 

Basic commands………………………………………………………………………….6

Working with files and directories  ……….……………………………………………..7

Permissions ……………………………………………………………………………....8

Special characters …………………………….………………………………………….9

OOOPS (dealing with mistakes) ………………..……………………………………….9

VI editor …………………………………………………………………………………10

 

HTML ……………………………………………………….11-13

            Basic page ……………………………………………………………….………………11

Tables ……………………………………………………………………………………12

Meta tags ……………………………………………………………………..………….13

 

SQL ……………………………………………………………13

 

Visual Basic ……………………………………………..…. 14-19

Procedures ……………………………………………………………………….…..…14

Syntax definitions ………………………………………………………………………16

Collection object ………………………………………………………………..………18

 

Java …………………………………………………….……19-23

Windows and Java …………………………………………………………….…………19

Coding Recommendations ……………………………………………………………….19

Example ………………………………………………………………………….………20

Installing and Using the Java SDK …………………………………………...………….21

More Examples …………………………………………………………………………..22

 

C++  …………………………………………………………23-28

Compiling ……………………………………………………………………..…………23

Debugging tips………………………………………………………………...………… 25

Pointers and functions ……………………………………………………………………25

Basic loop syntax …………………………………………………………………………27

 

 

Order of Operations ……………………………………….. 27

 

Basic Linked List………………………………………….... 28

 

Various Coding Examples ………………………………….29

 

Programming Tips ……………...………………………….. 31

 

Suggestions before getting help …………………………… 32

 

***NOTE***

 

This is NOT a substitution for your textbooks; this is just a quick-reference on basic elements and a guide to using some of the computers at school.  Use the guide to get started using the system at school.  Use the references and tips WITH your textbooks.

 

If you find any errors or would like us to add something to the guide please email the officers of UPE at:   upe@ecst.csuchico.edu

 

To access the “Survival Guide” online go to:  http://www.ecst.csuchico.edu/upe/survivor.html

 

 

 

 


Getting Started

 

ECT Computer Systems

The computer systems at CSU Chico are varied.  There are several computer labs with different types of equipment in them.  Here is a summary of the computer labs available in OCNL. There are also many other labs scattered across Campus for your use.

OCNL 133

Windows NT or 2000

OCNL 136

Sun Ultrasparc 10's (your back to the soda machine)
HP Pavilion, Windows 2000 (you facing the soda machine)

OCNL 241

Sun Ultrasparc 5's

OCNL 244

Mixed Unix Lab

OCNL 251

Windows NT or 2000

The primary server at the College of Engineering, Computer Science and Technology (ECST or ECT) is a Sun 3500 server named tiglon.  All of the servers at ECST are named for wildcats.  (see if you can guess what a tiglon is.  Hint, I always thought it should have been spelled tiglion.) Tiglon is replacing 27 HP workstations that were providing server facilities to the college.  Tiglon is more than capable of handling the load for many years to come.

Lynx is the ECST web server, although you will never have need to access it directly and most of its functions are hidden from the casual user. Students get to lynx's file system by accessing their public_html directory, which is linked symbolically to the lynx machine.

 

Accessing the ECT Computers Remotely

 

You can use telnet to access the servers (not the labs), although it is not recommended because it does not allow secure authentication with the UNIX system.  If you choose to do so anyway, you will be restricted from accessing the labs.  Instead, use ssh (secure shell) to log in.  There are several free ssh clients for the Microsoft Windows operating system.  One such client is PuTTY and can easily be found by browsing to http://www.google.com/search?q=putty+ssh. 

 

When you first log in to ect-unix.ecst.csuchico.edu, you will be prompted with a warning that the server’s host key is not cached.  This is expected since it has not been written yet.  You must say yes to this prompt to save the server’s key.  This should only happen the first time you log into a new server using ssh.

 

Getting and Using Putty

Putty is a telnet/ssh client that can be used to connect to a Unix system.  It will allow a text based connection to the ECT Unix systems at California State University, Chico.  Putty is a free download from:

 http://www.chiark.greenend.org.uk/~sgtatham/putty/

Putty is available on all of the Windows NT / 2000 machines in OCNL 251, OCNL 133 and OCNL 136.  It may or may not be set up for a connection to ect-unix.ecst.csuchico.edu.  Setting it up on these systems or on your home system is the same process.

Putty comes as a single executable file (putty.exe) that can be placed anywhere on a Windows system.  I find it convenient to just put it on the desktop.  When you open up Putty, you will get a screen similar to the following:

The "ect-unix' line will not be in the default Putty window.  You will need to input ect-unix.ecst.csuchico.edu into the Host Name text box and choose SSH as the Protocol.  Your window will look similar to the following:

You can click Save to save the settings for this session.  You will be prompted to give the session a name.  I chose ect-unix.  From now on, all you have to do is double-click on the ect-unix session and it will open a connection to ect-unix.ecst.csuchico.edu.

That connection will look similar to the following:

 

 

Login using your ECST Unix account login and password.  You will now be connected and logged in to tiglon, the application server at the College of Engineering, Computer Science and Technology and you will get a screen similar to the following:

However, your prompt will probably be just a dollar sigh ($) rather than the name of the host and the path information.  I have modified my prompt from the original.

From this screen, which is resizable, you will be able to enter Unix commands and also edit and debug your Java programs. 

Keep in mind that you can have multiple Putty windows open so you can edit and save in one window and you can compile in another.  This is what most developers do in order to save the time of exiting and then reloading a file for editing.

 

 

The Joy of Unix

 

Changing your password:

passwd                                                            Do this ASAP!

 

Cruising the Shell :

cd                                     moves you to your home directory

 

cd directoryname           moves you to that directory named directoryname

 

cd ..                                 moves you to the parent of the current directory

 

pwd                                  displays the path of the working (current) directory

 

ls                                      displays a listing of files in the current directory

 

ls -a                                 displays all f iles, including hidden f iles such as .profile and .login *

 

ls -l                                  displays more information on each file, including permissions

 

r command     r                will search command buffer as you type and will substitute a match..

                                        can save time when executing same command many times

 

clear                                  clears the screen

 

script  filename                starts a log f ile of your Unix session and writes it to filename

                                          end the script by typing Control-d

 

man commandname        displays documentation for that command, use space bar to move

                                          from page to page

 

man -k word                     displays all commands where word is a keyword

 

*Attempting to modify any of these special files can wreak havoc on your environment if you don't know what you are doing!

 

help commandnam           similar to man, less technical

 

exit                                     end the Unix session logout may also work

 

Working with Files and Directories:

mkdir directoryname       creates a subdirectory off of the current directory named

                                         directoryname

 

rmdir directoryname        removes the directory named directoryname from the current

                                         directory (the directory being removed must be empty first)

 

cp filel file2                        copies filel to file2

 

cp -i filel file2                    prompts for confirmation if file2 already exists

 

cp fname dname                 copies file fname into directory dname

 

rm filename                        deletes filename

 

rm - i filename                   prompts for y or n before deleting file

 

lpr –ppname  fname           prints the file fname to the printer pname

 

lpq -ppname                        shows the printer queue (including job numbers) for pname

 

lprm – ppname  jobnumber             removes jobnumber from pname's job queue

 

more filename                    shows the contents of filename, one page at time, use the

                                            spacebar to see the next page, q to quit

                                            also can be used as a "pipe" to control system output

                                            ex. ls –l |  more

 

page filename                   a little more versatile than more, press ‘-‘   to go back a

                                            page or type a number to go to that page

 

cat filename                     will display contents of filename

 

cat file1 file2 > file3         concatenates file1 and  file2into file3

 

Permissions:

Access to files and directories is controlled through the granting and revoking of permissions.  You must have permission to read (r), write(w) or execute(x) a file (even your own!), and similarly you must have permission to view filenames(r), add or delete files(w), or search through (x) a directory.  The owner (creator) of a file or directory can assign permissions to himself, to all members of a specific group, or to everyone.  You can view permissions for files by performing a long listing (ls -l).

 

The permissions will look something like this: _rwxrw_r_ _

The first space is only there to differentiate files from directories (blank for file, d for directory).  The following three characters (rwx) are the permissions for the owner aka user(u) of the file.  In this case the user has read (r), write(w) and execute(x) permissions.  The next three characters (r _ _) are the permissions for other members of the owner's group(g).  They have permission to read(r) and write(w).  The last three characters are the permissions for everyone else(o).  They only have read(r) permission.

 

chmod u=rwx,g=rw,o=r filename               Sets the above permissions for filename

chmod o+w filename                                    Grants write priviledges for filename to

others

 

chmod 777 filename                                     Grants all permissions to everyone for

          filename, using octal notation

 

 

 

 

 

Octal notation: Each group of 3 permissions is assigned a 3 digit binary value

·      22 21 20

r w x

 

                           _ _ _  = 0 = no permissions            _ _ 1 = 1 =  execute permission

                           _ 1 _ = 2 = write permission         1 _ _  = 4 =  read permission

 

111 = 4+2+1 = 7 = read, write and execute permissions

 

In general, your directory permissions should be set to: r wx     - - - - -  (700).

Permissions to your no non-executable files shouId be set to r w- - - - - - -(600), and

permissions for executable files should be set to r w x    - - - - - - (700).  This will

protect your work from being copied or vandalized by others.

 

Special Characters:

The following characters have special meaning in Unix and should not be used in

filenames:      &; | * ? ‘ “ [ ]  ( ) $ < > { } ^ # \ /

 

OOOPS:

If you need to stop a currently executing command (process),

 

kill anumber                          kills the process with the pid number anumber.

 

ki1l -9 anumber                    kills the process and all associated processes.

 

ps -u username                     displays all current processes (and their PID's) belonging to

                               username

 

ps -lu username                       displays more info about username's current processes

 

control-u                                   kills the current command line (before you hit enter)

 

control-c                                   may interrupt the current process

 

control-d                                   exits some processes (such as script)

 

control-z                                   sends a process to the background

 

control-h                                   erase a character

 

backspace                                 same

 

delete                                        same

 

Being a VIP (a VI (editor) Person)-.

VI operates in 2 modes.  When you start VI, you are in the command mode.  You can move around to different lines, delete text, copy, paste, save changes and exit VI.  In order to enter text you must change to input mode.  Input can begin before or after the cursor, before or after the current line, or on an entirely new line before or after the current line.  The same line editing commands available at the Unix command line work here also.  Within input mode you are restricted to editing the current line, or creating a new line.  To enter command mode from input mode, hit the escape key.  To return to input mode, hit either i, I, a, A, o, or 0, depending on where you wish text entry to start.  Sometimes the screen may become badly distorted.  This often happens across a Telnet when the buffer size is too large (over 25).  The screen can be repainted with the control-d key stroke combination.  Below is a listing of the most common VI editing commands.

 

COMMAND MODE:

            Move it:

                  H                                Top of screen

                  L         &n