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:
- Set up Raspbian on your Raspberry Pi 2 B
- Log into your Pi from your laptop
- Install Subversion to check out and commit your lab work.
- Explore a variety of command-line tools
The Equipment you need for this lab:
- Your Laptop (with Windows⊠if you use Linux or Mac, the instructions will be a little different)
- A Raspberry Pi 2 model B project board.
- A micro SD card (at least 8GB)
- An adapter that will let you plug the micro SD card into your laptop.
- A micro USB power adapter (or another way to get power into the pi).
- An Ethernet cable
Gather this stuff, make sure you have it all before you start.
Part 1: Setting up the Pi
Prep the Disk
- Download the latest Raspbian Disk Image onto your local machine. Itâs really big, so you may want to put it in ~/StaysOnPC.
- Unzip the file you downloaded.
- Stick the SD card into your laptop. Push hard enough so that you hear it click.
- Write the image onto your SD card. For this, follow the instructions on the raspberry pi site: here
- 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.
- 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.
- Be sure âLocal Area Connectionâ is selected from the âHome networking connectionâ drop-down box.
- 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!
- 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.
- 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.
- After about 30 seconds, open up âGit Bashâ or a Command prompt on your computer.
- 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.
SHOW YOUR INSTRUCTOR
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 directorycat <file>
: display the contents of a file.
Stage 1: Update your Pi
- 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
- 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 tiny.cc/cssepi ... pi@raspberrypi ~ $ bash cssepi ...
- 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 http://www.rose-hulman.edu/class/csse/csse132/
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 http://svn.csse.rose-hulman.edu/repos/1516c-csse132-<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 ~ $
SHOW YOUR INSTRUCTOR
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
- 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). - Submit the instructor verification sheet in hard copy.
- Before you power down the Pi, be sure to tell it to shut down. To shut it down, type:
Source: Working with your Pi