Cloud coding environment setup, Linux & C commands, the C compilation pipeline, system internals, and algebraic equation visualizers.
Environment
CS50.dev is a cloud-based VS Code environment used in the sessions. It requires a GitHub account to log in.
Session Commands
Commands used during the session — run these inside your Ubuntu terminal.
ls | List all files and folders in the current directory |
pwd | Print Working Directory — shows your current location in the file system |
clear | Clear the terminal screen |
touch sum.c | Create a new empty file named sum.c |
cat sum.c | Print the contents of sum.c to the terminal |
clang sum.c | Compile sum.c using the Clang compiler |
./a.out | Run the compiled program — default output file is always a.out |
rm a.out | Delete the a.out file |
clang sum.c -o sum | Compile and name the output sum instead of a.out |
./sum | Run the named executable |
When you run clang sum.c without -o, the compiler always creates a default output file called a.out (short for assembler output). Use -o <name> to give it a meaningful name.
clang --save-temps sum.c -o sum | Compile and save all intermediate files generated during compilation |
ls | List the directory — you will see all the files created |
After running --save-temps, the following files are generated:
bash file | Execute a bash script file directly |
Concept
The PATH is an environment variable that tells the operating system where to look for programs when you type a command. Without it, you would have to type the full location of every program every time.
When you type clang, the OS does not search your entire disk — it only looks inside the directories listed in $PATH, one by one, until it finds a match. If it finds nothing, you get command not found.
echo $PATH | Print the current PATH — shows all directories separated by : |
which clang | Show the full path to the clang executable — e.g. /usr/bin/clang |
which python3 | Show the full path to python3 — e.g. /usr/bin/python3 |
which gcc | Show where gcc lives on the system |
which ls | Even basic commands like ls are programs — which tells you where |
A typical $PATH looks like this:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
The OS checks /usr/local/sbin first, then /usr/local/bin, and so on. The first match wins.
./a.out | Run a.out from the current directory — ./ means "look here, not in PATH" |
a.out | Fails with command not found — the current directory is not in PATH by default |
The current directory (.) is intentionally left out of PATH for security — otherwise a malicious ls placed in any folder could run instead of the real one.
export PATH=$PATH:/new/dir | Append /new/dir to PATH for the current terminal session |
echo $PATH | Verify the new directory was added at the end |
Changes made with export last only for the current session. To make them permanent, add the line to your shell profile file: ~/.bashrc (Bash) or ~/.zshrc (Zsh), then run source ~/.bashrc.
Deep Dive
Understand what happens under the hood — how the operating system manages memory, processes, and hardware.