PuTTY – Configuration

Changing the Default Terminal Colors

This is a brief guide to changing the ANSI Blue/Blue Bold colors within PuTTY to modify the comment colors displayed in Vim.

Step 1: Open PuTTY and use the options tree on the left to select the following:

  • Window->Colours

Once on this property page there will be a selection of ANSI colors that can be changed.

Step 2: Look through the ANSI color list until the following two colors are found:

  • ANSI Blue
  • ANSI Blue Bold

Select the color you would like to change from within the list and press the “Modify” button. This will open a color-picking dialog where you can specify the color.

Step 3: At this point be sure to save the changes. This is done after you have changed the colors you want to modify. In the left hand property tree, select Session, type in a name for the session in the “Saved Sessions” text-field and then press the Save button.

At this point you should be able to connect to the UC Grid and use Vim. It should use your changed PuTTY settings (to overwrite the Vim defaults).

CSCI-1411-Using-nano

Quick Guide to Using nano

This guide describes the text editor nano and provides a quick introduction to using nano to author C++ source files.

This guide will show you how to open the nano application, create a C++ source file, save the file, and then exit.
This guide simply provides an introduction to using nano with some very basic commands. If you would like additional information on how to use nano there are many external resources. The more you use the program the better and more comfortable you will be using it.

HorizontalLine

Using nano to Create a C++ Source File

Step 0: Connect to the Unix CSE grid and login (The CSCI-1411 page contains guides on how to do this for both PC and Mac computers). Once you are at the Unix command line you can proceed to Step 1.

Step 1: Open the nano application by entering the command: nano and then pressing enter. This will open the nano application where you can start writing in a new file. If you would like to open an existing file then you can specify the file name after the command: nano test.cpp (If you give the file name and that file doesn’t exist then that is fine as well, nano will just know you intend to save the file under that name).

Nano open test.cpp

Nano open test.cpp

Step 2: Once nano is running you will be shown the screen below. Since nano is a simple text editor you can now type in the window as you would with any text editor. You can use the keys (but not the mouse) to navigate through the text that you write.

Nano Program Running

Nano Program Running

Step 3: Enter the following code to create a very simple C++ program (this is just an example, enter whatever code you would like).

Basic C++ Program in nano

Basic C++ Program in nano

Step 4: Now add a couple of comments to the code. They will be used to show you how to select, cut, and paste text. The following image shows the full C++ code with the added comments.

C++ Program with Comments

C++ Program with Comments

Step 5: To select text, move the cursor to where you would like to begin the selection, then press Ctrl+^ (that is the 6 key at the top of the keyboard – U.S.) Once you have pressed this short-cut move the cursor with the arrow keys to change what characters are selected. When you are happy with the text that is selected, press Ctrl+K to cut the text. Note: If you don’t select any text and use Ctrl+K it will cut the entire line that cursor is on.

Selecting text in nano (Ctrl+^)

Selecting text in nano (Ctrl+^)

Step 6: Move the cursor to the location where you would like to paste the text. When the cursor is at the correct location press Ctrl+U. This will paste the cut text at the new position. The following image shows that the word “Bottom” has been cut from the bottom comment and inserted into the top comment.

Nano Paste (Ctrl+U)

Nano Paste (Ctrl+U)

Step 7: When your done editing the file it can be saved by using the Ctrl+O short-cut (note that this is an ‘oh’ and not a Zero). Once you press the save short-cut you can enter the desired file name and press enter. This will save the file (if it reports that there is an existing file you can press ‘y’ for yes to overwrite the file).

Saving a file in nano

Saving a file in nano

If you need to look at any additional commands you can get the help page in nano by using the short-cut Ctrl+G

CSCI-1411-Using-vi

Quick Guide to Using Vim

This guide describes the text editor vi and provides a step-by-step guide to creating a C++ source file, editing the contents, and then saving the file. vi is a command-based text editor that provides advanced features for quickly editing text-based files from a terminal (command-line) interface. This program can be used from the command line by simply enter the command: vi. This will run the program and you can edit and save any kind of basic text file: text files (*.txt), C++ source files (*.cpp) and C++ header files (*.h). vi is included with almost every linux distribution (or some closely related alternative) and is pre-installed.

This guide will show you how to open the vi application, create a C++ source file, save the file, and then exit.
If you would like additional information about vi then there are several online tutorials. One of which is an interactive vim (note vi and vim are similar, vim is an extension of vi) emulator that allows you to practice using vim in a browser: Open VIM

Vim – A Command-Based Text Editor
When you first start using Vim you will notice that it is different than most simple text editors. Specifically if you open the program and start to type, the application will not enter any of the keys you are pressing. This is because Vim operates in two different modes: Command Mode and Insert Mode. Getting used to switching between these modes will take some time if your not familiar with this type of interface. Below is a brief description about both of these modes:

  • Command Mode: This mode is used to send commands to the Vim application. For example saving and quitting. To enter command mode press the Esc key.
  • Insert Mode: Allows you to enter text as you would in any text editor. To enter insert mode press the i key (i for insert).

HorizontalLine

Using Vim to Create a C++ Source File

Step 0: Connect to the Unix CSE grid and login (The CSCI-1411 page contains guides on how to do this for both PC and Mac computers). Once you are at the Unix command line you can proceed to Step 1.

Step 1: Open the vi editor using the following command: vi

Open vi (Enter the command: vi)

Open vi (Enter the command: vi)

Step 2: Once you have vi open, you will be shown the following screen. The application is now open and can be used to edit and create files. When you open Vim, the default mode is the command mode. If you type at this point it will not be entered into the Vim editor since it is in command mode.

Vim Default Screen

Vim Default Screen

Step 3: To insert some text into a new file press the i key to enter insert mode. After pressing the i key you will be able to type in the Vim editor. In this example a simple C++ Hello World program is typed into the editor.

Vim Simple Hello World Program

Vim Simple Hello World Program

Step 4: Once you have finished editing the files hit the Esc key to enter command mode. You can now save the file by typing the following command: :w test.cpp and hitting enter (where test is the name of the file you want to save this text to). Note: If it says that there is an overwrite problem then simply use the command: :w! test.cpp to force Vim to overwrite the file.

Saving in vi (:w filename)

Saving in vi (:w filename)

Step 5: To exit vi, ensure you are still in command mode and enter the following command: :q and press enter. This will close the vi editor.

vi Quit Command (:q)

vi Quit Command (:q)

If you have completed this guide then you should have a new test.cpp C++ source code file that you can compile and run.

CSCI-1411-Submit-Assignment

Submitting an Assignment on Canvas

This information is also on the Canvas website under Announcements
Carefully read the instructions in the Lab Assignment!

Submitting on Canvas
This guide shows you where and how to upload the files required for Lab1 (as an example).

Step 1: Open the Canvas website and log-in.
Step 2: On the left side there is a tab named Modules. Click the Modules link.

Canvas Course Modules

Canvas Course Modules

Step 3: Click on the Lab 1 assignment link (at the top of Lab-1 shown below in red)

Canvas Submit Assignment Link

Canvas Submit Assignment Link

Step 4: Click Add Another File to add another upload slot. You will have to add a slot for each file you want to upload. Carefully read the Assignment to see what files you need to upload!

Assignment Add Files (To submit more than 1 file)

Assignment Add Files (To submit more than 1 file)

Step 5: For each file you need to upload click Choose File and select the file from your computer.

Example: Lab1 Files to Submit

Example: Lab1 Files to Submit

CSCI-1411-Lab-Setup-Mac

Lab Setup Guide for Mac OS

This guide describes how to access the lab from an off-campus network with a Mac using the VPN and terminal. This has been tested on a Mac running OSX 10.5 and I successfully compiled and ran the sample hello world program through the Mac terminal. Download the appropriate VPN version from the link provided below (If your not sure what version of Mac OSX you have then click the apple at the upper-left corer of the desktop and select the About This Mac option).

This guide includes the following topics:

HorizontalLine

Note: Click on any of the images in this guide to see a larger version (for reading the terminal commands).

HorizontalLine

Accessing the UCD Network from an Off-Campus Network

To access the CSE grid with a computer that is not in the lab and is not connected to the UCD Wireless network you must use the UCD VPN. To use the UCD VPN just download it from the link provided above. Once the VPN application is installed it will allow you to connect to the CU-Downtown campus VPN. This guide will cover this process.

Step 1: Download the VPN from the UCD VPN Download Site. Its a simple Mac DMG installation image file.

Downloaded Mac VPN Client DMG

Downloaded Mac VPN Client DMG

Step 2: Mount the CiscoVPNClient by double clicking on the vpnclient.dmg file you downloaded in Step 1
Step 3: Find the mounted CiscoVPNClient either on the Desktop or use Go->Computer.

Mounted VPN Client

Mounted VPN Client

Step 4: Double clicking on the mounted CiscoVPNClient will open the disk image. You can now install the Cisco VPN Client by double clicking on the installation image (Click the cardboard-box above the text Cisco VPN Client.mpkg).

UCD VPN Installation Package

UCD VPN Installation Package

Step 5: Continue through the installation process just as you would for any other program installation. Once the application has been successfully installed, you can run it by going to Go->Applications->VPNClient

VPN Installation Beginning

VPN Installation Beginning

VPN Successful Installation

VPN Successful Installation

Step 6: Once you have the VPN Client running, click on UCD-Downtown Campus and click connect (in the upper-left corner). This will connect you to the UC-Denver campus VPN. When you are prompted, enter your UCD username and password (the same username and password used in the lab and for your UCD portal).

Running the VPN

Running the VPN

Connected to the UCD VPN

Connected to the UCD VPN

HorizontalLine

Using a Mac Terminal with SSH

This section describes how to use the Mac Terminal as a substitute for PuTTY. Using the terminal with the SSH command and PuTTY are equivalent for our purposes.

Step 1: Open the terminal. This is found in the Applications menu: Go->Applications->Utilities->Terminal.
Step 2: Enter the SSH command to connect to the CSE grid using secure shell like the example below. Note that once you enter this command and it successfully connects (assuming you are already connected to the VPN) it will display a warning related to the authenticity of the host.

  • ssh yourusername@csegrid.ucdenver.pvt
  • ssh transues@csegrid.ucdenver.pvt

Warning
The authenticity of host ‘csegrid.ucdenver.pvt (xxx.xxx.xxx.xxx)’ can’t be established.
RSA key fringerprint is …
Are you sure you want to continue connecting (yes/no)? yes

Terminal SSH Command

Terminal SSH Command

Step 3: Type yes to continue connecting to the CSE grid.
Step 4: When prompted, enter your password. After you have logged in you should see a prompt similar to what was shown with PuTTY. At this point you can use the Terminal just as you would use PuTTY (enter commands, compile code, run code).

Logged-in Terminal with SSH (like PuTTY)

Logged-in Terminal with SSH (like PuTTY)

Example Commands (compiling and running a progam)

Example Commands (compiling and running a progam)

HorizontalLine

Sharing a Folder with the CSE Grid

Using the built in command for connecting to a server: MacDesktop->Go->Connect to Server… a shared folder can be created between your Mac and the CSE grid (under your home directory). This can be used to upload files (like WinSCP in Windows) to the CSE grid server. If you are going to proceed with this guide and you are not connected the the UCD wireless network then you must be connected to the VPN.

Step 1: Open the connect to server dialog using: MacDesktop->Go->Connect to Server… This menu option is high-lighted in red below.

Connect To Server...

Connect To Server…

Step 2: In the Connect To Server dialog enter the following address: smb://csenas.ucdenver.pvt/yourusername. Note! Where it says yourusername you provide your UCD login username. When you have provided this Server Address in the top text field (as shown in the right image below), click the Connect button.

Connect To Server Dialog

Connect To Server Dialog

Server Address

Server Address (Mine as an example)

Step 3: In the resulting prompt, enter your UCD username and password. Once you are connected, a folder will open. This represents your home directory on the UCD grid.

Connect To Server Login

Connect To Server Login

You can now copy and paste files into this shared-folder and they will be uploaded to your home directory on the grid. You can use this to upload and download files.

CSCI-1411-Basic-Unix-Commands

Common Unix Commands

This page documents some of the basic Unix commands (specifically those used in class) and how should be used. In the guide below the command name will be shown in bold. If you have to provide additional information like the name of a folder (this name is called an argument) it will be shown in italics. Note: If you are using a Mac with the terminal you can also use these commands (Assuming that you are using the UCDenver VPN and you have connected to the CSE grid using SSH).

    HorizontalLine

  • ls
    (List) – Lists the files and directories in your current location. Use this command every time you would like to see what files and folders are in your current working directory (to check your current working directory use the pwd command.

    Example: I want to print the names of all files in the current directory.

    [username@ucdenvercsenode05 ~]$ ls
    main.cpp test.cpp firstprog.cpp
    [username@ucdenvercsenode05 ~]$

  • HorizontalLine

  • cd directoryname OR ..
    (Change Directory) – Changes your current working directory. The directory you change to must be shown when you use the ls command.

    Example: I want to change to the myHelp directory (go into the myHelp directory) and then I want to come back out of that directory. This shows the process of entering and exiting directories by specifying their name (to go into) and by using two dots .. to come out of a directory.

    [username@ucdenvercsenode05 ~]$ ls
    myFolder myHelp
    [username@ucdenvercsenode05 ~]$ cd myHelp
    [username@ucdenvercsenode05 myHelp]$ cd ..
    [username@ucdenvercsenode05 ~]$ ls
    myFolder myHelp

  • HorizontalLine

  • pwd
    (Print Working Directory) – This command prints the current working directory, that is, your current location in the directory hierarchy.

    Example: After logging in you can enter the pwd command to display your current position in the directory hierarchy on the CSE Unix grid. The output will be similar to the following.

    [username@ucdenvercsenode05 ~]$ pwd
    export/homes/username/
    [username@ucdenvercsenode05 ~]$

  • HorizontalLine

  • mkdir directoryname
    (Make Directory) – This command makes a directory in your current location. To check your current location use the pwd command.

    Example: I want to create a new directory named: myHelp. You can then display the new folder using the ls command.

    [username@ucdenvercsenode05 ~]$ mkdir myHelp
    [username@ucdenvercsenode05 ~]$ ls
    myHelp

  • HorizontalLine

  • rmdir directoryname
    (Remove Directory) – This command removes an existing directory. Note that you must match the name of the directory as it is shown by the ls command.

    Example: I want to remove the myHelp directory. List the contents of the current directory using ls, then remove the directory with rmdir.

    [username@ucdenvercsenode05 ~]$ ls
    myHelp
    [username@ucdenvercsenode05 ~]$ rmdir myHelp
    [username@ucdenvercsenode05 ~]$ ls
    [username@ucdenvercsenode05 ~]$

  • HorizontalLine

  • mv filename directoryname
    (Move) – Move the file given by filename to the specified directory given by directoryname

    Example: I want to move help.cpp into the directory myHelp. List the current directory with ls, then use the mv command.

    [username@ucdenvercsenode05 ~]$ ls
    myHelp help.cpp
    [username@ucdenvercsenode05 ~]$ mv help.cpp myHelp
    [username@ucdenvercsenode05 ~]$ ls
    myHelp
    [username@ucdenvercsenode05 ~]$ cd myHelp
    [username@ucdenvercsenode05 myHelp]$ ls
    help.cpp

  • HorizontalLine

  • nano filename
    (Nano Editor) – This command will open the Nano editor where you can edit the text of a file by using the terminal interface. For example you would not have to use WinSCP to upload a c++ source file, you could simply enter the command nano main.cpp. This would open the nano editor in the terminal and allow you to type in the file main.cpp. However since most labs contain source code from which you can work off of, I would suggest just uploading those files instead of retyping them. There are various tutorials on the internet that describe how to use nano.
  • HorizontalLine

  • vi filename
    (VIM) – Another text editor entirely controlled by keyboard short-cuts. Use this program if you feel that nano isn’t enough of a challenge. There are various tutorials online that explain the intricacies of this editor. If you don’t already know how to use this program and value your free time, I would suggest using nano or another text editor.

CSCI-1411-Lab-Setup

CSE Grid: User directories, Uploading files, and Compiling Programs

This guide illustrates how to setup a basic directory structure for this course, how to upload a C++ program file, and finally compile the uploaded C++ program. The lab computers have all of the required software so it does not need to be installed; however, to work from any location other than the UCD network (or in the lab) this software will have to be downloaded and installed. PuTTY and WinSCP are required for terminal access and file transferring. Download them from the links provided below:

This guide includes the following topics:

HorizontalLine

Note: Click on any of the images in this guide to see a larger version (for reading the terminal commands).

HorizontalLine

Logging Into the VPN from a Remote Computer

In order to use PuTTY and WinSCP you must first connect to the UC Denver VPN (which can be downloaded from the link below). Once you are connected to the VPN you can use PuTTY and WinSCP just as you would in the lab.

Step 1: Download and install the VPN for your operating system (Windows 8 versions may not be as stable as those designed for previous versions of Windows). Once you install the VPN and run it: Start->All Programs->Cisco Systems VPN Client->VPN Client

Cisco UCD VPN Client

Cisco UCD VPN Client

Step 2: Click on the UCD-Downtown Campus choise under Connection Entries. Then press the Connect button in the upper-left corner. This will connect you to the VPN and prompt you for a username and password. Use your UCD username and password (just like in the lab).

VPN Username/Password

VPN Username/Password

VPN Connected, Press Continue

VPN Connected, Press Continue

Step 3: At this point you can use PuTTY and WinSCP just as you would in the lab. When you are done with your work, disconnect from the VPN (make sure you disconnect when your done with school related work): Goto Start->All Programs->Cisco Systems VPN Client->VPN Client and then press the Disconnect button in the upper-left corner (it replaces the connect button).

HorizontalLine

Accessing the CSE grid with PuTTY

To use the CSE Unix grid we have to send commands via a terminal. PuTTY allows us to access the CSE Unix grid terminal from any computer (note: more on the CU VPN will be discussed later). Logging into PuTTY will connect you to the CSE Unix grid and allow you to send commands to setup the directories (folders) required for storing lab work. Click any of the images below to see a larger version.

Step 1: Enter csegrid.ucdenver.pvt into the PuTTY Host Name text field
Step 2: Enter CSEGrid into the PuTTY Saved Sessions text field
Step 3: Press Save (To save the CSEGrid session)

Default PuTTY Settings

Default PuTTY Settings

PuTTY with the appropriate settings

PuTTY with the appropriate settings

Step 4: When presented with the “login as:” prompt, enter your UCD username.

PuTTY Username Prompt

PuTTY Username Prompt

Step 5: When presented with the “Password:” prompt, enter your UCD password (Note! As you type the letters will not show so make sure you enter your password correctly).

PuTTY Password Prompt

PuTTY Password Prompt

Step 6: The following image shows the PuTTY terminal once you have successfully logged in. This is where you can now enter Unix commands (cd, mkdir, etc)

PuTTY Unix Console

PuTTY Unix Console

Step 7: Enter ls to list the contents of the current directory (when you first start there shouldn’t be any files).
Step 8: Enter pwd to print the current working directory.
Step 9: Enter mkdir csci1411 to create a new csci1411 directory (folder).

PuTTY Basic Commands

PuTTY Basic Commands

Step 10: Enter cd csci1411 to change to the newly created csci1411 directory (if you want to go ‘up’ a directory level from where you currently are use the cd .. command)
Step 11: Enter mkdir lab1 to create a new lab1 directory. This is where you will upload your Lab-1 files. Change to this directory using cd lab1. If you enter the command pwd at this time you should have the following: export/homes/yourname/csci1411/lab1/ shown in your PuTTY terminal.

Correct csci/lab1/ directory structure

Correct csci/lab1/ directory structure

Step 12: Use the command exit to disconnect and exit PuTTY

HorizontalLine

Uploading Files with WinSCP

To manage the files on the CSE Unix grid, WinSCP must be used. This application will allow you to easily upload and download files from your lab directories.

Step 1: Enter csegrid.ucdenver.pvt into the WinSCP Host name text field.
Step 2: Enter your UCD username into the User name text field.

WinSCP Default Settings

WinSCP Default Settings

WinSCP Modified Settings

WinSCP Modified Settings

Step 3: When prompted to save the session, save it.

WinSCP Save Session Settings

WinSCP Save Session Settings

Step 4: After the settings have been saved click the Login button at the bottom of the WinSCP window.

WinSCP Default Window

WinSCP Default Window

Step 5: When prompted, enter your UCD password. A Warning will appear: “The server’s host key was not found…”. Ignore this and select Yes. Click Continue when the UCD banner is shown.

WinSCP Password Prompt

WinSCP Password Prompt

Step 6: WinSCP will now show your documents on the left side window and the contents of your directory on the CSE Unix grid. As an example download the Hello World program: main.cpp and copy it to C:\Users\yourname\Documents. Then in WinSCP copy main.cpp from your documents directory to the csci1411 directory by clicking and dragging main.cpp into the right window of WinSCP. You can move through the directories on both your local computer and the CSE grid by double clicking the directory names in the WinSCP split-view window.

WinSCP Main Window

WinSCP Main Window

Step 7: In WinSCP goto the main menu: Commands->Quit to properly exit WinSCP.

WinSCP Quit Command

WinSCP Quit Command

HorizontalLine

Uploading Files with a Windows Mounted Folder

This method can be used instead of using WinSCP.
Windows allows you to create a networked folder on your computer (one that you can treat as a normal folder) that will connect with your account on the CSE grid server. You can upload and down load files just by moving them into (or out of) the networked folder. Note: You must be connected to the UCD VPN to do this remotely. Tested on Windows 7 (images from windows 7). If at any point your asked for your username and password, provide your UCD username and password (untested).

Step 1: Open Start->Computer and right click in the empty region below the list of drives. There should be an option to Add a network location. Select this option and it will open an Add Network Location Wizard.

Add Networked Drive

Add Networked Drive

Add Network Location Wizard

Add Network Location Wizard

Step 2: Follow the instructions through the wizard: Choose a custom network location and then enter the following address into the Internet or network address text field: \\csenas.ucdenver.pvt\yourusername\

Choose a custom network location

Choose a custom network location

Enter the network address with your own username

Enter the network address with your own username

Step 3: Once the wizard is complete you can now open the network folder. You can treat this folder like any folder (meaning cut, copy, paste, create files, etc).

Windows Networked Folder

Windows Networked Folder

HorizontalLine

Compiling and Running C++ Programs on the CSE Grid

C++ source code can be uploaded to the CSE grid to be compiled and executed. Once a source file has been uploaded to the CSE grid in your directory, it can then be compiled and executed. This section describes how to compile an uploaded source file (*.cpp) and execute it (run the program).

Step 1: Login to PuTTY (the same as shown at the top of this page).
Step 2: Navigate to the directory where you uploaded the main.cpp file. (For example if you uploaded it to csci1411\lab1\ then you would use: cd csci1411 then cd lab1). Once you are where main.cpp is use the ls command to show the contents of the directory (to ensure main.cpp is there).

Navigate to the location of main.cpp

Navigate to the location of main.cpp

Step 3: Compile the source file using the following command: g++ main.cpp. This will compile the main.cpp file into a program named a.out
Step 4: Run the program a.out by issuing the following command: ./a.out. Be sure to type it exactly as shown so the program will run. The result of the program is shown in the lower right image (program output is shown in red).

PuTTY Compile Main (command: g++ main.cpp)

PuTTY Compile Main (command: g++ main.cpp)

Run Main (command: ./a.out)

Run Main (command: ./a.out)

The resulting output of the program is the text “Hello World!”.

Step 5: Use the command exit to disconnect and exit PuTTY