CHAPTER 0: Getting Started with the Raspberry Pi¶
These instructions assume that you have a Raspberry Pi with the associated code already installed. If you are attending the CSinParallel 2020 Summer Workshop, you should have received either a Rapberry Pi Kit or a Raspberry Pi Image for use in conjunction with this workshop. We assume that you have already set up the Pi for initial use.
The following video gives an overview of the Raspberry Pi Kit and its assembly:
The following video shows how to connect to your Raspberry Pi using either SSH/PuTTY or a VNC client.
To SSH into your Pi from Mac OS X or Linux, use the following command:
The default password for the system is
raspberry. For security purposes, it is recommended that you change this password to one that you can easily remember.
You can also connect to the Raspberry Pi directly by plugging in an HDMI-enabled monitor and USB keyboard and booting up the system.
If you are using the latest Raspberry Pi 4 and want to connect to the system using an external monitor/keyboard/mouse, you will need a microHDMI cable to connect the HDMI monitor to the Pi. Older models have a full HDMI port and will not need this cable.
If you connect to the Pi by using an attached keyboard/monitor or remote desktop into it using a VNC client, booting up the Pi should yield a GUI interface to Raspbian, the Linux distro traditionally used with these machines.
For the rest of today’s workshop, you will primarily use the Terminal application and type commands into it, as if you had accessed the Pi using SSH or PuTTY. However, many students find it useful to see that the Raspberry Pi is actually a mini-computer; seeing the GUI interface really reinforces that fact.
0.1 Preliminaries: The Terminal application¶
If you are in a GUI environment, start the Terminal window by choosing its icon in the menu bar at the top (it looks like a black square box).
Type the following command into the Terminal window to get to the directory containing code for this tutorial:
ls command lists the contents of the current directory (in this case
ls command reveals that the
RaspberryPiBasics directory contains three subdirectories:
The rest of this writeup will lead you through some code found in above directories. These examples will let you explore how to write C code that will use the four cores available on the processor in the Raspberry Pi.
0.2 VERY useful terminal tricks¶
Tab completion of long names¶
You can complete a command without typing the whole thing by using the
Tab key. For example, make sure you are
still in the directory
/home/pi/CSinParallel/RaspberryPiBasics by typing:
Then try listing one of the three subdirectories by starting to type the first few letters, like this, and hit
Tab and see it
complete the name of the directory:
History of commands with up and down arrow¶
Now that you have typed a few commands, you can get back to previous ones by hitting the
up-arrow key. If you hit
up-arrow more than once, you can go back down to previous commands by hitting the
down-arrow key, all the way back to the prompt waiting
for you to type. You can get a blank prompt at any time (even after starting to type and changing your mind) by hitting the
CTRL and the
u key simultaneously together (i.e.
0.3 Editor Options¶
Your Raspberry Pi comes equipped with many editor options. For those of you who are famliar with standard command-line
editors, the Pi is equipped with
pico. For those readers who would like to use a
command line editor, we will briefly discuss
The Nano editor is extremely easy to use. To open up a file named
example.c, simply type
nano example.c into the
command line. The available commands are located at the bottom of the Terminal window. Common commands include saving (Write Out, or
exiting (Exit, or
CTRL-x), copying (Cut Text, or
CTRL-k), pasting (Uncut Text, or
CTRL-u), and Find (Where is, or
For those of you who prefer a GUI editor, the Raspberry Pi comes equipped with the Geany editor. If you are using the GUI interface,
you can simply go to the
Programming tab at the top of your screen.
For those of you who want to use Geany but are connected to the Raspberry Pi using PuTTY/SSH, it suffices to enable X tunneling.
For PuTTY, simply click “Enable X11 forwarding” under
Connection -> SSH -> X11 on the left-hand side of the PuTTY application.
For those of you using SSH, simply logon to the Pi using the command
ssh -X firstname.lastname@example.org.