unix-foundations Lesson 1 20 min read

What is Unix? From System to Shell

How a 50-year-old operating system still powers the modern world — and why you're about to learn it

Reading: Linux Text: Ch. 1–2, pp. 1–45

After this lesson, you will be able to:

  • Open a terminal and identify the shell prompt components (username, hostname, directory, privilege indicator)
  • Run basic informational commands (whoami, hostname, date, uname, cal, pwd, ls)
  • Explain what the shell does when you type a command (the REPL loop and PATH search)
  • Distinguish absolute paths from relative paths and use ~, ., and ..
  • Navigate the Unix file system tree and identify key directories (/home, /usr/bin, /etc, /tmp)

Why Should You Care About an Operating System from 1969?

Here’s something that might surprise you: the Java programs you wrote in CSCD 210? They ran on a C program. The JVM — that thing that made javac and java work — is written in C and C++. Every time you typed ./gradlew test, a chain of C programs did the heavy lifting underneath.

This quarter, you’re going to learn that language, and this is the operating system where it was born.

But before we write a single line of C, we need to get comfortable in the environment where C lives: Unix. And the doorway into Unix is something called the shell.

Think of it this way. In CSCD 210, you lived inside VS Code — an IDE that handled file management, compilation, and output for you. Now imagine stripping all of that away and replacing it with a single blinking cursor. That cursor is the shell, and it’s more powerful than any IDE menu.


From Bell Labs to Your Terminal

The Unix Origin Story (and Why It Matters)

In 1969, Ken Thompson and Dennis Ritchie at AT&T Bell Labs started building an operating system on a spare PDP-7 minicomputer. By 1973, Ritchie had created the C programming language specifically to rewrite Unix in a portable way. That decision — writing an OS in a high-level language instead of assembly — changed computing forever.

Big Picture: C and Unix were born together. Learning one deepens your understanding of the other. When you understand how Unix processes work, C’s fork() and exec() make perfect sense. When you understand C’s memory model, you’ll understand why Unix commands are small and fast.

The Unix philosophy boils down to three principles:

  1. Do one thing and do it well — each command has a focused purpose
  2. Combine tools via pipes — small programs chain together into powerful pipelines
  3. Text is the universal interface — programs communicate through plain text streams

You’ll see all three of these in action by Week 2.

Where Unix Lives Today

Unix didn’t stay in Bell Labs. It branched into a family tree:

  • BSD → FreeBSD, OpenBSD, and macOS (yes, your Mac runs Unix)
  • System V → Solaris, HP-UX, AIX
  • Linux (1991, Linus Torvalds) → Ubuntu, Fedora, Debian, Android

We’ll use Ubuntu 24.04 in this course — a Linux distribution that’s POSIX-compatible with Unix (POSIX is a standard that defines how Unix-like operating systems should behave — if a system is POSIX-compatible, the same commands and APIs work on it). When we say “Unix commands,” they work the same on Linux, macOS, and most other Unix-like systems.

The Shell: Your New Interface

When you open a terminal, you’re talking to a shell — a program that reads your commands, interprets them, and runs other programs. The shell is a REPL, just like you might have used in a Java debugger:

  1. Read — waits for you to type a command
  2. Evaluate — interprets what you typed
  3. Print — shows the result
  4. Loop — goes back to waiting

Key Insight: The shell is a REPL (Read-Eval-Print Loop). It reads your command, interprets it, finds and runs the program, displays the output, and then waits for the next command. Every shell session is this loop, over and over.

Your prompt might look something like this:

student@ubuntu:~$

Breaking that down: student is your username, ubuntu is the machine name, ~ means you’re in your home directory, and $ means you’re a regular user (as opposed to # for the root/admin user).

Your First Commands

Let’s start typing. Open your terminal and try these:

whoami

This prints your username. Simple, but it confirms you’re logged in and the shell is listening.

hostname

The name of the machine you’re on. On your VM, this might be ubuntu or something you configured.

date

Current date and time. Notice something: you didn’t need to import java.util.Date or create an object. You just typed a word and got an answer. That’s the Unix way.

uname -a

System information — kernel name, version, architecture. The -a is a flag (also called an option). Most Unix commands accept flags that modify their behavior. Flags usually start with - (short form) or -- (long form).

cal

A calendar for the current month. Try cal 2026 for the whole year.

From Java: In CSCD 210, displaying a calendar meant importing libraries, writing a class, writing a main method, compiling, and running. In Unix, it’s one word: cal. This is the power of having hundreds of small, focused tools.

Check Your Understanding
You type cal into the terminal and a calendar appears. What made that happen?
A The shell has a built-in calendar — it generated the output itself.
B The shell found a separate program called cal on your system and ran it.
C The kernel directly executed the calendar command without the shell's involvement.
D The terminal application (not the shell) interpreted and ran the command.
The shell is a middleman. When you type cal, the shell searches your PATH for a program named cal, asks the kernel to create a process and run it, and then displays the output. The shell itself doesn't know anything about calendars — it just knows how to find and run programs.

What Happens When You Type a Command

When you type ls and press Enter, here’s what actually happens:

  1. The shell reads your input: ls
  2. The shell searches for a program named ls in directories listed in your PATH variable
  3. The shell asks the kernel (the core of the operating system) to create a new process and run the ls program
  4. ls runs, reads the directory, and writes its output to stdout (standard output — your screen)
  5. The shell displays a new prompt, ready for your next command

This process happens for every command you type. The shell is a middleman between you and the operating system.

Exploring Your File System

Now let’s see where you are and what’s around you:

pwd

Print Working Directory. This tells you your current location in the file system. You’ll probably see something like /home/student. Think of it as your GPS coordinates in the directory tree.

ls

List the contents of your current directory. You’ll see file and directory names.

ls -l

Long format — now you see permissions, owner, size, date, and name. This is the format you’ll use most often.

ls -a

Show all files, including hidden ones. Hidden files start with a . (dot). You’ll see .bashrc, .profile, and other configuration files.

ls -la

Combine both. This is probably the command you’ll type most this quarter:

drwxr-xr-x  5 student student 4096 Mar 30 14:22 .
drwxr-xr-x  3 root    root    4096 Mar 28 09:00 ..
-rw-r--r--  1 student student  220 Mar 28 09:00 .bash_logout
-rw-r--r--  1 student student 3771 Mar 28 09:00 .bashrc
drwxr-xr-x  2 student student 4096 Mar 30 14:22 cscd240

Don’t worry about the permission strings yet (that’s Lesson 1.4). For now, notice that d at the start means “directory” and - means “regular file.”

The File System is a Tree

Unix organizes everything in a single tree structure rooted at / (called “root” — not to be confused with the root user). Every file, every device, every running process has a location in this tree.

/                          ← root of the entire file system
├── home/                  ← user home directories
│   └── student/           ← YOUR home directory (~)
│       └── cscd240/       ← course directory
├── usr/                   ← user programs and libraries
│   └── bin/               ← system commands (ls, cp, gcc)
├── etc/                   ← system configuration files
├── tmp/                   ← temporary files
└── dev/                   ← device files (yes, hardware shows up as files!)

Paths describe locations in this tree. There are two kinds:

  • Absolute paths start with /: /home/student/cscd240/lab1
  • Relative paths start from wherever you are: cscd240/lab1

Special shortcuts:

  • ~ = your home directory (/home/student)
  • . = current directory
  • .. = parent directory (one level up)

From Java: In CSCD 210, VS Code showed you a file explorer panel with a tree view. You clicked folders to navigate. In Unix, you navigate that same tree structure with commands: cd to move, pwd to check where you are, ls to see what’s around you. The tree is the same — the interface is different.

Safety First

Common Pitfall: New Unix users fear typing commands because they worry about breaking something. Here’s the truth: most commands are read-only. Commands like ls, pwd, cat, whoami, and date just display information — they can’t damage anything. The destructive commands (rm, mv, chmod) are clearly identified, and we’ll mark them when we get there.

To end your session, type:

exit

Or close the terminal window. Either way, your files are safe.

Check Your Understanding
What does the ~ character represent in a Unix path?
A The root of the file system (/)
B The current working directory
C Your home directory (e.g., /home/student)
D The parent directory (one level up)
~ is a shortcut for your home directory. The shell expands it to the full path, like /home/student. The current directory is ., the parent is .., and the root of the entire file system is /.
Quick Check: What does the shell do when you type date?

The shell reads your input, searches for a program named date in the directories listed in PATH, asks the kernel to run it, date writes the current date/time to stdout (your screen), and the shell shows a new prompt.

Quick Check: What's the difference between an absolute path and a relative path?

An absolute path starts with / and specifies the full location from the root of the file system (e.g., /home/student/cscd240). A relative path starts from your current directory (e.g., cscd240/lab1). The ~ shortcut expands to your home directory’s absolute path.

Quick Check: Why is the JVM relevant to this course?

The JVM is written in C and C++. When you ran Java programs in CSCD 210, you were relying on a C program underneath. This course teaches you the language and OS that power tools like the JVM.


Why This Foundation Matters

You now have a mental model for what Unix is and how the shell works. Every command you’ll learn this quarter follows the same pattern: you type, the shell interprets, a program runs, output appears. That’s it.

But right now, you’re standing in your home directory with only pwd and ls to look around. In the next lesson, you’ll learn to navigate — creating directories, moving files, and building the project structure you’ll use for every lab this quarter.

Big Picture: The workflow for this entire course is: edit code (in VS Code or a terminal editor), compile it (with gcc in the shell), run it (in the shell), test it (in the shell), and submit it (with git in the shell). The shell is not just a tool — it’s your primary development environment. Getting comfortable here is step one.