Lab 0 — Intro to Odin & Unix Basics

Goal Get comfortable logging into CSUB's Odin server, navigating the Unix filesystem, editing files with vim, managing permissions, and compiling/running simple programs. This lab sets you up for success in all later labs.

Estimated time: 60–90 minutes

Prerequisites

Part A — Log in to Odin via SSH

  1. Open Terminal/Command Prompt/Powershell on your device.
  2. Connect using SSH (replace YOUR_USER as appropriate):
    $ ssh YOUR_USER@odin.cs.csub.edu
  3. First-time prompts: type yes to trust the host key, then enter your password (typing is hidden).
  4. Success looks like a welcome message and a shell prompt, e.g. YOUR_USER@odin:~$.

Troubleshooting: If SSH hangs or fails, verify the hostname, your password, and that you’re on a network that allows outbound SSH (port 22).

Part B — Filesystem Basics

Create your course directory

  1. From your home directory:
    $ pwd
    /home/stu/YOUR_USER
    $ mkdir cs3600
    $ ls
    cs3600 other_stuff
  2. Now create a public folder and second course directory:
    $ cd ~/public_html
    $ mkdir cs3600
    $ cd cs3600
    $ pwd
    /home/stu/YOUR_USER/public_html/cs3600
  3. Create an index.html file and add the following structure:
    <!DOCTYPE html>
    <html>
      <body>
        <pre>
        First Last Name
        CMPS 3600
        Fall 2025
    
    
        <b>Lab 0</b>
        <img src="./images/lab0_output.png" style="width:auto; height:420px" /> <br>
        </pre>
      </body>
    </html>
    		
  4. Make a subdirectory for images:
    $ mkdir images
    Save your screenshot in images/lab0_output.png so it appears when you view the page.

Part C — Edit Files with vim

vim has two main modes: Normal (navigation/commands) and Insert (typing). Keys:

  1. Edit readme.txt:
    $ vim readme.txt
  2. Press i to insert, then type a short note. Press Esc, then :wq and Enter to save & exit.
  3. Verify the change:
    $ cat readme.txt

Part D — File Permissions (Basics)

Use ls -l to see permissions. Example:

$ ls -l readme.txt
-rw-r--r-- 1 YOUR_USER YOUR_GROUP 37 Aug 27 10:05 readme.txt

The left string (-rw-r--r--) is permissions: owner/group/others. Common changes with chmod:

CommandEffect
chmod u+x run.shAdd execute for you (user)
chmod go-rw secret.txtRemove read/write for group/others
chmod 644 file.txtNumeric mode: rw-r--r--

Tip: Directories need the x bit to be entered (cd) and the r bit to list contents.

Part E — From C++ to C, Makefiles, and CLI

1) Start with a simple C++ program

Create hello.cpp that prints a greeting and sums numbers.

// hello.cpp
#include <iostream>
using namespace std;

int main(int argc, char* argv[]) {
    cout << "Hello from C++!" << endl;
    int sum = 0;
    for (int i = 1; i < argc; ++i) sum += stoi(argv[i]);
    cout << "Sum: " << sum << endl;
    return 0;
}

Compile and run on Odin:

$ g++ -std=c++17 -Wall -Wextra -O2 -o hello_cpp hello.cpp
$ ./hello_cpp 3 4 5
Hello from C++!
Sum: 12

2) Refactor to C

Create hello.c (use stdio/stdlib and atoi):

/* hello.c */
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {
    printf("Hello from C!\n");
    int sum = 0;
    for (int i = 1; i < argc; ++i) sum += atoi(argv[i]);
    printf("Sum: %d\n", sum);
    return 0;
}

Compile and run:

$ gcc -std=c17 -Wall -Wextra -O2 -o hello_c hello.c
$ ./hello_c 3 4 5
Hello from C!
Sum: 12

3) Create a Makefile

In the same directory, make a file named Makefile:

# Makefile
CXX := g++
CC  := gcc
CXXFLAGS := -std=c++17 -Wall -Wextra -O2
CFLAGS   := -std=c17   -Wall -Wextra -O2

all: hello_cpp hello_c

hello_cpp: hello.cpp
	$(CXX) $(CXXFLAGS) -o $@ $<

hello_c: hello.c
	$(CC) $(CFLAGS) -o $@ $<

run-cpp: hello_cpp
	./hello_cpp 1 2 3

run-c: hello_c
	./hello_c 1 2 3

clean:
	rm -f hello_cpp hello_c

Use it like this:

$ make        # builds both
$ make run-c  # runs C program with sample args
$ make clean  # removes binaries

4) Deliverables

Submission

Unless otherwise instructed, submit via the department server under your cs3600/lab0/ directory and follow your instructor’s directions for notifying completion.

Checklist