Code Instructions

  1. Make sure you have VirtualBox installed, Linux installed on it, and can boot into it. (See the instructions on the website if you don’t have it working yet

  2. Make sure you know how to access the Terminal program in Linux, and have installed gcc and a text editor of your choice (vim, emacs, nano, etc.)

  3. From inside Linux, open Firefox, then go to https://github.com/remzi-arpacidusseau/ostep-code/archive/refs/heads/master.zip to download the code from the book. Save it anywhere (maybe inside your home directory somewhere)

  4. Unzip it, and note where you unzipped it to.

  5. Close Firefox, then go back to the Terminal. Navigate to the code you just unzipped using cd command.

  6. Inside that folder, navigate to the “intro” directory, which is the code for Chapter 2 of your book.

  7. Install the ‘make’ program to “make” your life easier (pun intended): sudo apt install make

  8. Once you are in the intro folder, compile all of the files by typing make, then hitting ENTER.

    • Note: you could compile these yourself manually too. For example, to compile the “cpu.c” file, type gcc -o cpu cpu.c, then hit ENTER. This will compile it to a program called “cpu”.
  9. To run the cpu program, type: ./cpu "hello" (ctrl-c will stop the program, since it is an infinite loop)

  10. Try to run the other code samples from Chapter 2 of your book (all of them are in the “intro” directory.