Exploring The Raspberry Pi And Raspbian Debian Wheezy

The Experiment: In this experiment were going to explore the Raspberry Pi and Raspbian Debian Wheezy.  This content on this page for reference use only.

Table of Contents
1. What i a Respsberry Pi
2. Handy Window Tools
3. Installing Raspbian Debian Wheezy
Prepare Your SD CardPi
• Hook Up Your Raspberry Pi
Configure Your RaspberryPi
Get Your Raspberry Pi IP address
4. After The Raspbian Debian Wheezy Install
• Change the default  “pi” password
Update / Upgrade Raspbian
Create a user
Remove a user
5. The Network
• Set a Static IP Address
6. USB Drives
Installing a USB Flash Drive
7. Command Notes

What is a Raspberry Pi
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python.

Handy Windows Tools
1. PUTTY (SSH client)
2. WinSCP (SSH File Transfer)
3. Win32DiskImager
4. SD Formatter

Installing Raspbian Debian Wheezy
You will need: A 4GB Class 4 SD card (or better)A HMDI to VGA adapter or  Video cableA VGA monitor or TVA USB keyboard,  A USB mouseA Ethernet cable

Prepare Your SD Card
1. Download Raspbian Debian Wheezy (windows .zip)
2. Un-zip the Raspbian Debian Wheezy image (write down the folder name)
3. Launch Win32DiskImager
4. Select the Raspbian Debian Wheezy.img file
5. Select the device (SD card drive letter)
6. Leave Copy (un-ckecked)
7. Click Write (this will take at least 30minutes)
8. Un-plug the SD card

Hook Up Your Raspberry Pi
1. Place the SD card into the raspberry Pi SD slot
2. Connect everything to the Raspberry Pi
3. Now connect your Raspberry Pi to the micro USB power adapter

It’ll turn on all by itself and you should see it boot for the first time

Configure Your Raspberry Pi
raspberrypi login: pi <enter>
password: raspberry <enter>
Now type:
pi@raspberrypi ~$ raspi-config <enter>

1. Select expand_rootfs (the second option) and press enter
2. Confirm that you want to expand the file system and let Raspbian do its thing
3. When you’re returned to the configuration list, go all the way to the bottom and select the Finish option
4. It’ll ask you if you want to reboot. Choose yes

Get Your Raspberry Pi IP address
raspberrypi login: pi <enter>
password: raspberry <enter>
Now type:
pi@raspberrypi ~$ ifconfig <enter>

Write down the inet addr:

Now if you have the PUTTY(Client) installed on your PC you can remotely access your Raspberry Pi with that IP address


After The Raspbian Debian Wheezy Install

Change the default  “pi” password:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To change the “pi” password type:
pi@raspberrypi ~$ passwd <enter>

The passwd command allows you to change your password, you will be prompted for your old password, then you new password twice. Once this is done then the next time you log in you will need to use the new password.

1. From a command line prompt type passwd followed by the Enter key
2. Enter your current password followed by the Enter key
3. Enter your new password followed by the Enter key
4. Re-enter your new password followed by the Enter key
5. Your password has now been changed

Now logout type:
pi@raspberrypi ~$ Logout <enter>

Now log back in with “pi” and the new password
raspberrypi login: pi <enter>
raspberrypi password: <your new password> <enter>


Update / Upgrade Raspbian:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To update the system type:
pi@raspberrypi ~$ sudo apt-get update <enter>

Wait for this to complete

Now upgrade the system type:
pi@raspberrypi ~$ sudo apt-get upgrade <enter>

Wait for that to complete, answer any prompts with ‘y’ + Enter.
Your system is now up-to-date.

Last clear all downloaded package files (.deb files) from the archives folder
to free up space on the SD card type:
pi@raspberrypi ~$ sudo apt-get clean <enter>


Create a  user:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To Create a new user type:
pi@raspberrypi ~$ groups <enter>

You will see a list similar to the one below:
pi adm dialout cdrom sudo audio video plugdev games users netdev input

Now to create a new user, but remember to use your list of groups (minus the first ‘pi’ item) and replace <username> with the user  you want to create type:
pi@raspberrypi ~$ sudo useradd -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev, input <username> <enter>

Next set a password for your new user type:
pi@raspberrypi ~$ sudo passwd <usernsme> <enter>

Complete the prompts as they appear.

Now shutdown the raspberry pi type:
spi@raspberrypi ~$  sudo shutdown -h now <enter>

The raspberry pi will boot up and leave you in a Bash shell asking for a login name: Log-in with your newly created user’s name


Remove a user:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To Remove a user type:
pi@raspberrypi ~$ sudo deluser –remove-all-files <usernsme> <enter>

This will take a little while and spit out a lot of lines of text – eventually it will say ‘Done’. This removes user and it’s associated files from the system.


The Network

Setting a Static IP Address
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

First, we need to list the network interface we currently have available type:
pi@raspberrypi ~$ cat /etc/network/interfaces <enter>

The line iface eth0 inet dhcp, implies that we’re currently getting our IP address via DHCP, meaning it’s being dynamically registered by the router. This is what we want to change!

Next we need to grab some information from our router and Pi type:
pi@raspberrypi ~$ ifconfig <enter>

This reveals your router information, the bit you want is after eth0 (the Ethernet connection)
eth0 Link encap:Ethernet HWaddr b8:27:eb:b3:fc:2c
inet addr: Bcast: Mask:

Write down the following information:
inet addr – (the Pi’s Current IP Address)
Bcast – (The Broadcast IP Range)
Mask – (Subnet Mask Address)

We need a little more information before we proceed type:
pi@raspberrypi ~$ netstat -nr <enter>
(route -n will give you the same info)

Write down the following information:
‘Gateway’ Address –
‘Destination’ Address –

Now we need to enter this information into the Pi’s network config file type:
pi@raspberrypi ~$ sudo nano /etc/network/interfaces <enter>

change the line that reads:
iface eth0 inet dhcp
iface eth0 inet static
Then directly below that line enter the following
(Please Note: You will need enter your own xxx.xxx.xxx.xxx addresses information)
address xxx.xxx.xxx.xxx inet addr
netmask xxx.xxx.xxx.xxx Mask
network xxx.xxx.xxx.xxx Destination
broadcast xxx.xxx.xxx.xxx Bcast
gateway xxx.xxx.xxx.xxx Gateway

Now save before exit, CTRL+X (exit) then “y” to save changes!

Now reboot and check your changes type:
pi@raspberrypi ~$ sudo reboot <enter>

Then Log back in
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>
pi@raspberrypi ~$ ifconfig <enter>

verify your new settings

To double checks if all is working as it should, ping your ‘Gateway’ Address type:
pi@raspberrypi ~$ ping xxx.xxx.xxx.xxx -c 10 <enter>

(the -c 10 command simply denotes that you want to ping it 10 times, if you forget to add this, it will ping the address continuously. To stop it press CTRL+C)

Quick Guide:

Write down the inet addr:, Bcast:, Mask: IP address
netstat -nr
Write down the Gateway, Destination IP address

sudo nano /etc/network/interfaces
1. Place # before iface eth0 inet dhcp
2. Copy/Past everything in Bold type after that
   Note: address = <your static IP address>
   Note: netmask, network, broadcast, gateway = <your IP address>
auto lo

iface lo inet loopback
#iface eth0 inet dhcp
iface eth0 inet static


allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

3. CTRL+X (exit) then “y” to save changes
4. sudo reboot


USB Drives

Installing  a USB Flash Drive
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

Plug your Flash drive into the Pi, then type:
pi@raspberrypi ~$ sudo fdisk -l <enter>

You’ll see a list of storage devices attached to the Pi; one is the SD card, the other is the drive you just plugged in. The SD card will be the one identified as /dev/mmcblk0 and will likely have a number of ‘partitions’ listed under it. We are interested in the other one; for me that is /dev/sda, and it has one partition ‘/dev/sda1′ yours will likely be the same, but check, and use your value in the following commands rather than mine. We’re going to format the partition on the USB drive so Linux has a clean slate to use – this will erase any data on the card.

Remember to use the value you got for your USB drive if it’s different to mine type:
pi@raspberrypi ~$ sudo mkfs.ext4 /dev/ <your flash drive> <enter>

The USB drive is now blank and in a Linux native filesystem format. Now we need to mount it (i.e., let Linux actually use it)

First we create a mount point (a directory name we will access the drive from) type:
pi@raspberrypi ~$ sudo mkdir /<your director name> <enter>

and then we actually mount the drive onto that mount point type:
pi@raspberrypi ~$ sudo mount /dev/ <your flash drive> /<your director name> <enter>

The drive is now available to the root user… but no one else has permission to access it
We can change that as follows type:
pi@raspberrypi ~$ sudo chgrp -R users / your director name> <enter>

Now any user belonging to the ‘users’ group can access the drive
But they can’t write to it yet type:
pi@raspberrypi ~$ sudo chmod -R g+w / <your director name> <enter>

The last job is to set up auto-mounting. Right now, if you rebooted the Pi then the /websites directory would be inaccessible because the drive would need to be re-mounted
That’s annoying, so we’ll automate that type:
pi@raspberrypi ~$ sudo nano /etc/fstab <enter>

You’ll see a somewhat complicated looking file. We just need to add a new line to it at the bottom and separate each item on the line with a tab – be sure to press the tab key where you see [tab] instead of writing the phrase [tab] enter: /dev/YOUR flash drive [tab] /websites [tab] ext4 [tab] defaults [tab] 0 [tab] 2

Save file, Press Ctrl+X to exit, “y” then Enter to save


Command Notes

!$ – history function: runs last command
pwd – print name of current/working directory

mkdir – make directories

nano hello.c – create new file