Most students who take this course have their own laptop, but you will need to install some free software. (If you do not have access to a laptop, let me know before the term begins so that we can chat about alternatives.)
In this class, in addition to learning about the hardware and organization of a computer, you will be writing and compiling several C programs, and submitting them using git, all from a Unix/Linux/bash command line. You will also be using Markdown for homework assignments, presentation reflections, and other written work that does not need fancy formatting. Thus, you will need:
The first class will include an introduction to Unix/Linux/bash, and the process we will be using for downloading, editing, compiling, running, and submitting programs. You should be sure to have the requisite software before the first class. As part of installation, you should test that it works, so make sure to read and follow the Simple Test section below.
Mac Users: You already have Unix (a Mac runs on Unix under the covers), but you should download XCode if you don't have it already to get the command-line development tools. XCode is a free Apple application on the App Store, but it is big and slow to download so do it when your machine is going to be in one place for awhile. If you have access to a wired Ethernet connection, use that to speed things up. I also recommend that you open up the Terminal app (which is already on your machine) and add it to your dock so that you can bring it up quickly throughout the term.
Windows Users: You will probably need to download and install the Windows System for Linux (WSL), although some versions of Windows may come with it already installed in which case you just need to enable it. You can check your Windows Features first for the Windows System for Linux, and check it to enable it if it is there. If not, here is a link with installation instructions: https://learn.microsoft.com/en-us/windows/wsl/install. This has gotten much easier than it was a few years ago, but students still occasionally run into an issue somewhere, in which case the TAs in the Collaboration Center can be a big help. Waiting until Week 1 to set this up, though, is not a good idea. (If you are running an old version of Windows, upgrading to the current version is strongly recommended.) The Linux subsystem should come with gcc, make, and git, three tools that you will be using extensively in this course.
Linux Users: If you currently run Linux on your laptop, you are probably all set! Your system should have gcc, make, and git already there.
Many students have chosen to use Visual Studio Code (https://code.visualstudio.com/download) to edit both C and Markdown files, although you can use any editor that produces plain text. Examples include vi/vim, emacs, VS Code, Brackets + Brackets Markdown Preview, Atom, etc. VS Code also provides Markdown previewing. You may also want to install a Markdown extension in Chrome and tell it to interpret Markdown files from www.cs.kzoo.edu and kit.cs.kzoo.edu.
If you want to learn vi, aka vim, you may find the "vi 101" link on this Basic Vi page useful. (Vim stands for "vi improved", and when most people refer to "vi" they actually mean the improved version. On many systems, in fact, the "vi" command is now just an alias for "vim". At the level of the Basic Vi page, both versions are the same.)
mkdir subdir
("make directory" with name subdir)cd subdir
("change directory", i.e., move to subdir)cd
(if no subdir provided, change to "home" directory)pwd
("print working directory", i.e., show where I am)ls
(list files in this directory)code fileOrDirectory
(bring up VSCode for file or all files in directory)vi file
(bring up vi for file, i.e., edit file)gcc sourceFile.c
(Gnu C Compiler -- compile sourceFile.c)whereis cmd
(show where cmd is in the filesystem)
The easiest way to test that you have the right software and that it works is to create a tiny "Hello, World!" program. This will also serve as your first chance to practice editing, compiling, and running a program from the command line.
whereis gcc (alternatively, whereis cc)
whereis make
whereis git
The output of each of these commands should be a full pathname of the
command, showing where it was installed. (You don't really care where it
is installed, so long as it is somewhere.)
cd (this will go to your "home directory" on this system) pwd (this will show you the full pathname of your home dir) mkdir cs230 (make a directory called cs230 -- or whatever you want) cd cs230 (change directory to the new directory -- use whatever you called it) pwd (this will show you the full pathname of your new dir) mkdir hello (make a directory called hello -- or whatever you want) cd hello (change directory to the new directory -- use whatever you called it) pwd (this will show you the full pathname of your newest dir)
Now bring up an editor to type in your "Hello, World!" program. If you want to use VS Code, type
code hello.c (will bring up VS Code)
(If you want to usevi
, typevi hello.c
instead.)
Ignore any offers of extensions or Co-Pilot. For this class, you want the most basic version of VS Code possible.
In the editor, type (or copy-and-paste) the following program into your
hello.c
file:
/** This is a simple program to test that the software to * edit/compile/run C programs is installed and working. * * Author: Kernighan and Ritchie, The C Programming Language * * Typed in and run by: Your Name, Date */ #include <stdio.h> int main(int argc, char * argv[]) { printf("Hello, World!\n"); }
If you copied-and-pasted, make sure it copied the angle brackets around
stdio.h
, not the HTML source (in other words
"<stdio.h>
", not "<stdio.h>
").
Edit the program to add your name and the date in the comments.
Then save the program.
(If you are choosing to learn vi, type ESC
, then
:w
to write or :wq
to write and also quit).
ls (will "list" the files in this directory; should have hello.c) gcc hello.c (will compile your program, creating a.out) ls (you should now see a.out, as well as hello.c) ./a.out (will run a.out in the current directory)You should see the output from the program at the command line.
If you're interested in reading a little more about Unix/Linux before the term begins, you may find some of the slides on this page interesting or useful, especially the basic commands on this Intro to Unix page.