Get Started with CS50.dev

CS50.dev is a cloud-based VS Code environment used in the sessions. It requires a GitHub account to log in.

Linux & C Commands

Commands used during the session — run these inside your Ubuntu terminal.

File System
lsList all files and folders in the current directory
pwdPrint Working Directory — shows your current location in the file system
clearClear the terminal screen
Working with Files
touch sum.cCreate a new empty file named sum.c
cat sum.cPrint the contents of sum.c to the terminal
Compiling & Running C
clang sum.cCompile sum.c using the Clang compiler
./a.outRun the compiled program — default output file is always a.out
rm a.outDelete the a.out file
clang sum.c -o sumCompile and name the output sum instead of a.out
./sumRun 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.

Compilation Stages — Save Intermediate Files
clang --save-temps sum.c -o sumCompile and save all intermediate files generated during compilation
lsList the directory — you will see all the files created

After running --save-temps, the following files are generated:

sumFinal executable
sum.iPreprocessed source
sum.bcLLVM bitcode
sum.sAssembly code
sum.oObject file
sum.cOriginal source
Bash Script
bash fileExecute a bash script file directly

System PATH

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.

View the PATH
echo $PATHPrint the current PATH — shows all directories separated by :
which clangShow the full path to the clang executable — e.g. /usr/bin/clang
which python3Show the full path to python3 — e.g. /usr/bin/python3
which gccShow where gcc lives on the system
which lsEven 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.

Why ./a.out needs the dot-slash
./a.outRun a.out from the current directory./ means "look here, not in PATH"
a.outFails 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.

Add a Directory to PATH
export PATH=$PATH:/new/dirAppend /new/dir to PATH for the current terminal session
echo $PATHVerify 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.

System Internals

Understand what happens under the hood — how the operating system manages memory, processes, and hardware.