Getting started with your Raspberry Pi

I’ve had my Raspberry Pi since May 2012 and I’ve been running the very first Raspbian for most of that time. However, I’ve installed and uninstalled a lot of stuff in that time so I decided to update my Raspberry Pi to the latest release of Raspbian.  I thought that I’d make a note of all the things that I had to do to get it back up and running to a state where I can use all of the GPIO functionality with the projects that I’ve built. This is not a comprehensive guide, rather it’s a collection of my thoughts and steps to get my RPi going.

Get the latest image and put it on your SD card

Head over to http://www.raspberrypi.org/downloads and grab the latest Raspbian image file.  Follow their comprehensive guide to installation using the OS of your choice.  My (old) laptop runs CrunchBang linux (which runs very smoothly and is great for communicating with the RPi).

Boot up the RPi and configure

Connect up the RPi to an HDMI TV/monitor, keyboard, and network (via an ethernet cable). Boot for the first time and go through the raspi-config tool.  The only important step is to expand to fill your SD card (I also overclock to 900 MHz).

Set up wifi

When I first got my RPi and installed the default image on the SD card setting up wifi was a real pain. However, with the latest Raspbian image set up is a real breeze.  I have an Edimax micro USB adapter which is supported out of the box.

While your RPi is still plugged into the monitor/keyboard login to the command line shell.  Enter the command:

cat /etc/network/interfaces

This will show you the configuration for the network interfaces installed on your Rpi.  Notice that the output will configure the wlan0 interface to use wpa_supplicant which provides a way of storing information about the wireless networks that you are going to connect to.  The wpa_supplicant file.conf needs editing manually to register your wireless network.  Enter the command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and apend the following information to the end of the file:

network={
ssid="__YOURSSID__"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="__YOURKEY__"
}

Now we need to test the configuration by issuing the following commands.

sudo ifdown wlan0
sudo ifup wlan0

You should now see the blue light flashing on your adapter indicating that it is active (the output may give you a couple of ioctl errors which can be ignored). You can now check what your ip address is by issuing the command:

sudo ifconfig

You should now be connected to your wireless network and you can shutdown your RPi and run it in headless mode (no monitor).

Remote Desktop Access

It may be useful to access the desktop of your RPi from another computer.  In order to achieve this you should follow the guide at Penguin Tutor:

http://www.penguintutor.com/linux/raspberrypi-headless

Edit your .bashrc file

I have my own custom .bashrc file that I like so the next step is to load that onto the RPi. Here it is for anyone that’s interested:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
 debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
 xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
 if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
 # We have color support; assume it's compliant with Ecma-48
 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
 # a case would tend to support setf rather than setaf.)
 color_prompt=yes
 else
 color_prompt=
 fi
fi

if [ "$color_prompt" = yes ]; then
 if [ -n "$SSH_CLIENT" ]; then
 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:
\[\033[01;34m\]\w\[\033[00m\]\$ '
 else
 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:
\[\033[01;34m\]\w\[\033[00m\]\$ '
 fi
else
 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
 PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
 ;;
*)
 ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
 test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dirco
lors -b)"
 alias ls='ls --color=auto'
 #alias dir='dir --color=auto'
 #alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
 alias fgrep='fgrep --color=auto'
 alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
alias ll="ls -l --group-directories-first"
alias ls='ls -hF --color' # add colors for filetype recognition
alias la='ls -Al' # show hidden files
alias lx='ls -lXB' # sort by extension
alias lk='ls -lSr' # sort by size, biggest last
alias lc='ls -ltcr' # sort by and show change time, most recent l 129
ast
alias lu='ls -ltur' # sort by and show access time, most recent l 130
ast
alias lt='ls -ltr' # sort by date, most recent last
alias lm='ls -al |more' # pipe through 'more'
alias lr='ls -lR' # recursive ls
alias tree='tree -Csu' # nice alternative to 'recursive ls'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
 . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
 . /etc/bash_completion
fi
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s