Raspberry Pi Setup

What is the Raspberry Pi?

The Raspberry Pi is a cheap computer designed by the Raspberry Pi Foundation (UK registered charity) to help kids build knowledge and experience in the computer Science, engineering and programming fields. Read more here: http://www.raspberrypi.org/about and here http://en.wikipedia.org/wiki/Raspberry_pi )>.


My Raspberry Pi Setup

The Raspberry Pi is a very forgiving device to get started on, first you plug in your power (mine was a USB cable), SD card. keyboard, mouse, monitor (HDMI) and turn it on. My SD card was empty and nothing booted so i..

  • Downloaded NOOBS (Off-line Installer:) http://www.raspberrypi.org/downloads
  • Installed SD Card Formatting Tool: https://www.sdcard.org/downloads/formatter_4/eula_mac/
  • Performed an overwrite Format on my SD card.
  • Copied the contents of noobs13.zip to the Pi.
  • Booted the pi (with hdmi, kbrd and mouse plugged in).

Basic Commands

How to safely shutdown the OS.

    sudo halt

How to update all os packages

    sudo rpi-update (Sorry I had “dpi-update” before)
    sudo apt-get update && sudo apt-get upgrade

Setting up a FTP server (so you can upload files to the Pi from another PC).

    sudo apt-get install proftpd
    Restart the FTP Service:
    sudo service proftpd restart

Networking Setup

I had issues with a raspberry Pi that was already on my network (a Pi driven 24/7 webcam that was built by the awesome Brisbane Storm Chasers, my camera uploads images to the http://webcams.bsch.au.com/index.htm weather cam network for my http://www.twitter.co/2340weather twitter feed.

How to change the Pi’s name:

    sudo hotname SiPi01

Change the Pi’s name permanently:

    sudo nano /etc/hostname
    sudo nano hosts

    tip: change to SiPi01

Check network Interfaces:

    cat /etc/network/interfaces

How to check the network connection:



    sudo reboot

I also wanted my ADSL router to give the SiPo01 the same IP every time. so I followed this guide to set a Static IP.

    This ended up being my config.

Keyboard Setup

I noticed my keyboard setup was set to UK and # symbols were not working. This allowed me to reset the keyboard to whatever region I wanted.

sudo dpkg-reconfigure keyboard-configuration
sudo reboot
sudo raspi-config

Sound Stuff

Enabling audio on the 3.5mm audio jack (not HTML sound).

I followed this guide: http://www.raspberrypi-spy.co.uk/2013/06/raspberry-pi-command-line-audio/

    How to install an easy mp3 player called mpg321: http://www.include.gr/debian/mpg321/

      Quick Summary:
      sudo apt-get install mpg321

    How to Play a MP3 file.

      sudo mpg321 -g 50 RogerWaters-FletcherMemorialHome.mp3

    How to turn the volume up:

      alias volu='sudo amixer set PCM -- $[$[amixer get PCM|grep -o [0-9]*$|sed 's/%//')+10]%'

    How to set command line aliases to type the stuff above for your when you type “volup.”

      sudo nano ~/.bash_aliases

      Add the following lines:

      # increase volume by 5%
      alias volup='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+5]%'

      # decrease volume by 5%
      alias voldown='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-5]%'

      Now you can type “volup” and “voldown” to change the volume.

First BASH Script

Make a folder for scripts to live in.

    mkdir /usr/bin/simon

Change to the new scripts folder.

    cd /usr/bin/simon

Make a script file.

    sudo nano testScript001

Make the script file executable.

    bash -x testScript001
    First Script Contents

      I wont bore you with details line by line but the script outputs a few system variables, tests the internet connection, downloads a file the exits.


      printf "Hello, $USER\n"

      OS_TYPE=$(uname -o)
      printf "OS Type: $OS_TYPE\n"

      OS_VER=$(uname -r)
      printf "OS Version: $OS_VER\n"

      CPU_TYPE=$(uname -m)
      printf "CPU TYPE: $CPU_TYPE\n"

      _IP=$(hostname -I) || true
      if [ "$_IP" ]; then
      printf "IP: $_IP\n"

      printf "BASH Version: $BASH_VERSION\n"

      printf "Today's date: $DATE\n"

      echo "Pi Updtime:"
      printf "\n"

      printf "Testing Internet Connection (https://www.websitenameremoved.com):\n\n"
      # ping -q -t 10 -w1 -c1 https://www.websitenameremoved.com
      wget -q --tries=2 --timeout=20https://www.websitenameremoved.com/
      if [[ $? -eq 0 ]]; then
      printf "Internet appears online.\n\n"

      if [ -f $TMP_FILE ]
      echo "Deleting old temp files.."
      sudo rm ./simple_text_file.txt
      printf "Downloading file from the internet.\n"
      sudo wget https://www.websitenameremoved.com/test/simple_text_file.txt
      if [ -f $TMP_FILE ]
      printf "File downloaded ok.\n"

      printf "Internet appears offline, unable to download files."

      printf "Goodbye\n\n"

    All you do to run the script is type the following.

    • sudo ./testScript001

Setting the script to run every 15 minutes

    sudo nano /etc/crontab

    Add the following line at the end of crontab to run the script every 15 minutes:

      # */15 * * * * root /usr/bin/simon/testScript001

Misc Commands

Viewing the startup script (that executes after each user logs in)

    sudo apt-get install mpg321

Installing a Webcam Driver

    sudo apt-get install fswebcam

      Capturing a Webcam Image:
      /usr/bin/fswebcam -r 960x720 -d /dev/video0 /home/pi/webcam.jpg