Lab #1: Getting Started with Linux
Linux & Vim Lab #1 – Exercises
BEGIN HERE for LAB #1
This phase of Lab #1 has you learn how to login and enter a program. These instructions will also help you prepare when it is time to submit programming assignments to D2L. All steps should be completed! Pay close attention to the instructions
- Get set up to use the lab system
- Learn how to create and submit programming assignments for this course
- Become familiar with the linux operating system
Getting Starting with LABS:
- Power-up your computer
- Connect to PSU’s network (PSU or PSU Secure) using your CS login and password
- PC using Windows:
- Install ssh or putty
- Double click on the ssh or putty icon
- For putty, experiment with different colors and text sizes (Window – Appearance)
- Use Host name of
cs162lab.cs.pdx.edu
if you are in CS162. Otherwise, use the appropriate host name for your class.- CS162 labs will use
cs162lab.cs.pdx.edu
- CS163 labs will use
cs163lab.cs.pdx.edu
- CS202 labs will use
cs202lab.cs.pdx.edu
- CS299 labs will use
cs299lab.cs.pdx.edu
- CS162 labs will use
- Open a session and login
- MAC OS X Only:
- Open Finder and navigate to Applications.
- In Applications, navigate to Utilities.
- Find Terminal and double-click it.
- Use Host name of
cs162lab.cs.pdx.edu
if you are in CS162. Otherwise, use the appropriate host name for your class as described earlier. - Once you have a Terminal open, simply type (using the correct host:
ssh username@cs162lab.cs.pdx.edu
- Linux Only:
- Open Terminal (control t on PSU’s chromebooks)
- Use Host name of
cs162lab.cs.pdx.edu
if you are in CS162. Otherwise, use the appropriate host name for your class as described earlier.- CS162 labs will use
cs162lab.cs.pdx.edu
- CS163 labs will use
cs163lab.cs.pdx.edu
- CS202 labs will use
cs202lab.cs.pdx.edu
- CS299 labs will use
cs299lab.cs.pdx.edu
- CS162 labs will use
- Type at the linux prompt based on the class you are in:
ssh username@cs162lab.cs.pdx.edu
Navigate to the directory for the first lab
- CS162 Students:
cd CS162/Lab1
- CS163 Students:
cd CS163/Lab1
- CS202 Students:
cd CS202/Lab1
- CS299 Students:
cd CS299/Lab1
- CS162 Students:
Now, create a program get familiar with a linux editor, C++ compiler that we will be using, and how to run a program. Enter in the following program using one of the following editors:
- CS162 students may use: nano, pico, vi, vim or emacs
- CS163, CS202, and CS299 students need to use: vi, vim or emacs
Start by editing a C++ file: nano cs162_lab1.cpp
Type in the following sample program using a linux editor
//My name:_______________
//Sample program to get familiar with linux
#include <iostream>
using namespace std;
int main()
{
//Output a message to welcome the user!
cout << “Welcome to Computer Science!”;
return 0;
}
- When done entering the program, save your work.
- We recommend saving work frequently
- Start small and incrementally build your programs
- Never write more than a single function without compiling and running your program!
- Compile your C++ source code file. “No news is good news!”
g++ cs*_lab1.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++ cs*_lab1.cpp
Once there are no compile errors, run your program by typing:
./a.out
Submit your program by typing ./submit from the Lab1 directory
Next… Learn about Assignments!