Working with your Pi

You'll work on this lab individually (but it's ok to ask other students for help). In this lab, you'll set up Linux on your Pi and get some experience with command-line tools. Goals:

  1. Set up Raspbian on your Raspberry Pi 2 B
  2. Log into your Pi from your laptop
  3. Install Subversion to check out and commit your lab work.
  4. Explore a variety of command-line tools

The Equipment you need for this lab:

  1. Your Laptop (with Windows… if you use Linux or Mac, the instructions will be a little different)
  2. A Raspberry Pi 2 model B project board.
  3. A micro SD card (at least 8GB)
  4. An adapter that will let you plug the micro SD card into your laptop.
  5. A micro USB power adapter (or another way to get power into the pi).
  6. An Ethernet cable

Gather this stuff, make sure you have it all before you start.

Part 1: Setting up the Pi

Prep the Disk

  1. Download the latest Raspbian Disk Image onto your local machine. It's really big, so you may want to put it in ~/StaysOnPC.
  2. Unzip the file you downloaded.
  3. Stick the SD card into your laptop. Push hard enough so that you hear it click.
  1. Write the image onto your SD card. For this, follow the instructions on the raspberry pi site: here
  2. Remove the SD card from your laptop. To do this from windows, first you must “eject” it via “Safely remove hardware”. Once Windows has finished with it, push the card to eject it.

Prepare the Network

Next, you need to set up a small local network so your computer can talk to the Pi! Be sure to do all this before you turn on your Pi.

  1. Open “Network and Sharing Center” via the wifi system tray icon.

2. Select “Wireless Network Connection” to configure.

3. Select “Properties”, and authenticate as an Administrator.

4. Select the “Sharing” tab, and check the box to allow other network users to connect through your Internet connection.

  1. Be sure “Local Area Connection” is selected from the “Home networking connection” drop-down box.
  2. Click “OK” buttons until all the network configuration windows are gone.

Mac OS X: Go to System preferences > Sharing > Internet sharing. Share your wireless connection to your ethernet.

Ubuntu: Go to System Settings > Network > Wireless > little arrow by your connected network > Settings > IPv4 Settings > Method: Shared to other computers

Hook up the Pi!

  1. Pull the microSD card out of the adapter, and insert it into the Pi.

2. Connect your Ethernet cable to your laptop and the Pi.

3. Plug the AC adapter into a power outlet and into the Pi.

  1. Admire the lights on the circuit board. There should be lights in two places: on the top by the SD card and on the network port. Oooh. Pretty.
  2. After about 30 seconds, open up “Git Bash” or a Command prompt on your computer.
  3. Check if the Pi is alive using the command ping raspberrypi.local. If you don't see something like the following, it's not connected.

7. Once you've verified the pi is alive, close your command prompt.

Take Control

Now that you know it's connected and alive, it's time to log in! Use SSH to log into the pi. You'll use the same program (SecureCRT, Putty or your favorite SSH client) that you used in Lab 1. To log in,

Choose user “pi” and the default password “raspberry”. Here's what it looks like in Git Bash:

Expand the Filesystem

The image you installed was intentionally small. If you have a small SD card, it will fit. It also fits big ones! In order to maximize the space on your card, you need to use a command called raspi-config.

pi@rasperrypi ~ $ sudo raspi-config

After typing the command, you'll get a screen with a menu. This is a tool that can do tons of things with your Pi. You may want to explore its options later, but for now we'll focus on the first one.

Choose the “Expand Filesystem” option. Follow the instructions, then exit raspi-config. Allow the Pi to reboot. After it reboots, log back in using SSH.

Change your Password

Once you're logged in, change your password! Pick a new password for the user “pi” that you will remember. Pick a good one, and launch sudo raspi-config again. This time, choose the second option: “Change User Password”. The system will hide the password as you type it in! This is for security; don't worry, when you press ‘enter' it will have the password you typed in.

Change your Hostname

In raspi-config, go into the “9 Advanced Options” section, then choose “A2 Hostname”. You're going to change the name you call the Pi to <rhit username>-pi. For example, if your Rose-Hulman username is stammsl, change the hostname to stammsl-pi.

After you've done this, exit raspi-config and allow the pi to reboot.

Log back in. Since you changed the hostname, instead of using raspberrypi.local to log into your pi, you will use <username>-pi.local from now on.


Now is a great time to print out the instructor verification sheet and show your instructor.

Part 2: Practice with the Pi

Now it's time to play around with the pi through a terminal. When the pi is waiting for you to give it instructions, it'll show you a prompt. The prompt looks like this:

pi@raspberrypi ~ $

This means you are logged in as pi on a computer called raspberrypi and you are in the ~ directory (your home directory). The dollar sign ($) is a visual indication for you to type something.

For the rest of this lab, you're going to use a number of linux commands. Here's a quick reference for some of them:

  • cd <dir>: change directory. For example, cd foo is like opening the folder “foo” and going inside. cd .. goes back up a directory.
  • ls: show a list of the files in the current directory
  • cat <file>: display the contents of a file.

Stage 1: Update your Pi

  1. In order to run things as an administrator (for example, to install programs), you need to use a command called sudo. This temporarily turns you into an admin called root. Try it!pi@raspberrypi ~ $ whoami pi pi@raspberrypi ~ $ sudo whoami root
  2. To update the pi, first we want to install support for the CSSE update mirrors. This way you won't use your quota to install software. This is two commands: one to download the script, another to run it.pi@raspberrypi ~ $ wget ... pi@raspberrypi ~ $ bash cssepi ...
  3. Once all the info is downloaded, you can install updates via apt-get upgrade. This will trigger download of software updates from the software mirror at Rose.pi@raspberrypi ~ $ sudo apt-get upgrade

Follow the instructions (if it gives you any).

Stage 2: Install a command-line web browser

Since your sole access to the pi is via command line, lets install a browser that works in a text-only environment! To do this, use apt-get.

pi@raspberrypi ~ $ sudo apt-get install links

It will ask you if it's ok to install stuff. Type “y” and hit enter.

Once it's installed, launch it and see if you can view the course website! (Hint: hit the “ESC” key to show menus and “q” to quit).

pi@raspberrypi ~ $ links

Stage 3: Install subversion

Next, you need the subversion client so you can get your lab materials. Use apt-get to install it!

pi@raspberrypi ~ $ sudo apt-get install subversion

Stage 4: Check out your SVN repository!

The command below checks out your repo. Be sure to replace <username> with your RHIT username.

pi@raspberrypi ~ $ svn --username <username> co<username>

Once it's checked out, use the cd command to go into the directory, and the ls command to show your repository's contents.

pi@raspberrypi ~ $ cd 1516c-csse132-<username>/
pi@raspberrypi ~ $ ls
lab01         lab02         lab03
pi@raspberrypi ~ $


Your instructor will want to check that you've gotten this far, so now is a great time to show your instructor.

Stage 5: Solve the mystery

Use cd to navigate into your lab03 directory. Once you're in there, use the ls command to list that directory's contents. You'll notice a file that you should read! Read it using the cat command and follow its instructions.

When you've solved the mystery, show it to your instructor and get checked off!

Finishing the Lab

  1. Submit the electronic files you create to svn (from your Pi, using svn add <file> for each file.). In all of your files, be sure to include your name and your partner's name (for future labs).
  2. Submit the instructor verification sheet in hard copy.
  3. Before you power down the Pi, be sure to tell it to shut down. To shut it down, type:

Source: Working with your Pi

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top