Lab #1: Getting Started with Linux
Linux & Vim Lab #1 – Programming Assignments
Now that a complete program has been entered, compiled and submitted on our lab system, it is time to get familiar with the computer system used for programming assignments this term. Please make sure to read the background information that preceded this lab, as it discusses the uses and availability of the lab system in comparison to the MCECS linux system:
- It is assumed at this point that the computer being used has been powered on and is connected to the PSU or PSU Secure system
- PC running Windows Only:
- Double click on the ssh or putty icon
- Use Host name of
linux.cs.pdx.edu
- Open a session and login
- MAC Only:
- Open Finder and navigate to Applications.
- In Applications, navigate to Utilities.
- Find Terminal and double-click it.
- Once you have a Terminal open, simply type:
ssh username@linux.cs.pdx.edu
- Linux Only:
- Open Terminal (control t on PSU’s chromebooks)
- Type at the linux prompt:
ssh username@linux.cs.pdx.edu
The very first time that you login to linux.cs.pdx.edu to work on your Computer Science assignments, create a directory where your programs will reside (and where you will work from). You won’t need to do that for the Lab work…just for your individual programming assignments.
- To make a new directory use the linux mkdir command:
- CS162 students should type:
mkdir CS162_Programs
- CS163 students should type:
mkdir CS163_Programs
- CS202 students should type:
mkdir CS202_Programs
- CS299 students should type:
mkdir CS299_Practice
- CS162 students should type:
- To make a new directory use the linux mkdir command:
- From then on, you will need to change into that directory to get your work done. This will need to happen each time!
- To change into the directory to work type:
cd CS*_Pr*
Or, you can specifically type in the directory name:
- CS162 students should type:
cd CS162_Programs
- CS163 students should type:
cd CS163_Programs
- CS202 students should type:
cd CS202_Programs
- CS299 students should type:
cd CS2
99_Practice
- CS162 students should type:
- To change into the directory to work type:
Then, you might consider creating a separate directory for each of your programming assignments. This is especially important for CS163 and CS202 students, since each assignment will contain multiple files.
mkdir Prog1
← Do this only once to create a directory
cd Prog1
- Now just for practice, type in the same program using an approved linux editor (e.g., the same editor you used for the first part of this lab):
nano prog1.cpp
When done entering the program, save your work.
- Compile your C++ source code file. “No news is good news!”
g++ prog1.cpp
If there are errors, use the editor again to modify your program
- Once the errors are corrected, save your work and exit the editor
- Re-compile your C++ program:
g++ prog1.cpp
Run your program by typing:
./a.out
IMPORTANT!!
DO NOT SKIP THE STEPS!!!!
THESE Instructions MUST BE CAREFULLY FOLLOWEDSecure Transfers: Linux to D2L
The next step is very important and will prepare you for turning in programming assignments to D2L. Please do not skip this step. In this step, we will practice:
- Transferring the program (.cpp file) from linux
- Uploading the file to D2L to submit.
You may need additional software to perform this action on a PC or Mac. There is free software available that can be used to perform a “Secure File Transfer”. Refer to the background information on submitting programs for more information.
- While connected to the linux.cs.pdx.edu system, transfer your program from linux to your desktop
- We recommend
Cyberduck
, using Secure ftp (SFTP) - On a Linux system, use the
filezilla
. Seek assistance from the lab assistants. Often files are lost or transfers are not successful.
- We recommend
- Once you have transferred your .cpp file to your own computer
- Upload it to D2L’s dropbox to the “Practice Dropbox Folder”
- Make sure to hit the Submit button on D2L after uploading, otherwise your file will not actually be stored in D2L
- If you used a school computer, make sure to delete the file from the school’s hard drive!