"

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:

  1. 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
  2. PC running Windows Only:
    1. Double click on the ssh or putty icon
    2. Use Host name of linux.cs.pdx.edu
    3. Open a session and login
  3. MAC Only:
    1. Open Finder and navigate to Applications.
    2. In Applications, navigate to Utilities.
    3. Find Terminal and double-click it.
    4. Once you have a Terminal open, simply type:
      ssh username@linux.cs.pdx.edu
  4. Linux Only:
    1. Open Terminal (control t on PSU’s chromebooks)
    2. Type at the linux prompt:
      ssh username@linux.cs.pdx.edu
  5. 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.
    1. 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
  6. From then on, you will need to change into that directory to get your work done. This will need to happen each time!
    1. 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 CS299_Practice
  7. 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
  8. 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
  9. When done entering the program, save your work.
  10. Compile your C++ source code file. “No news is good news!”
    g++ prog1.cpp
  11. If there are errors, use the editor again to modify your program
  12. Once the errors are corrected, save your work and exit the editor
  13. Re-compile your C++ program: g++ prog1.cpp
  14. Run your program by typing:
    ./a.out

    IMPORTANT!!

    DO NOT SKIP THE STEPS!!!!
    THESE Instructions MUST BE CAREFULLY FOLLOWED

    Secure 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.

  1.  While connected to the linux.cs.pdx.edu system, transfer your program from linux to your desktop
    1. We recommend Cyberduck, using Secure ftp (SFTP)
    2.  On a Linux system, use the filezilla. Seek assistance from the lab assistants. Often files are lost or transfers are not successful.
  2. Once you have transferred your .cpp file to your own computer
    1. Upload it to D2L’s dropbox to the “Practice Dropbox Folder”
    2. Make sure to hit the Submit button on D2L after uploading, otherwise your file will not actually be stored in D2L
    3. If you used a school computer, make sure to delete the file from the school’s hard drive!

License

CS Linux & Vim Manual Copyright © by Karla Fant. All Rights Reserved.

Share This Book