Raspberry Pi – Setup steps

This is a quick guide for getting a Raspberry Pi with Raspbian up and running. This article is aimed at those with some technical experience of the Unix Shell and is purely intended as a checklist of things to do – aimed purely at reminding myself what should be done on a new machine, but others may find this useful too.

First, download Raspbian

Grab the latest Raspbian image from RaspberryPi.org

Download Win32DiskImager

Grab Win32DiskImager and use it to burn the Raspbian image to a MicroSD card.

Initial Boot

Boot the Pi with a monitor and keyboard. On first boot Raspbian Jessie should automatically restart and increase the disk image to the full size of the Memory Card (earlier versions of Raspbian/Wheezy had required you to do this manually from raspi-config).

When the boot has completed, login with:

pi / raspberry

Immediately reset the default password to something more secure:

~# passwd

Enter raspberry for the current password, then enter your new password.

Secure root

The root user comes with no password. Although this ordinarily may be fine, I still prefer to secure it with a strong password.

Switch to the root account from the pi account, then apply a new password to the account with the following commands:

~# sudo su
root~# passwd

Note: ‘passwd’ won’t ask you for the current password for root as there isn’t one set.

Exit the root shell by typing:

root~# exit

Add Wifi support (if required)

Run the command:

~# sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Append the following to the conf:


Where NETWORKNAME is the SSID/name of your wifi network. The “password” is the password. If you run your Wifi network using other configurations than standard PSK, you should google for more info on setting up Wifi via the Shell on Linux. The “ssid” and “psk” properties must be lowercase.

Then press: ‘ CTRL+X ‘ then ‘ Y ‘ to close and confirm save of changes.

Once you have saved the config file, reboot the Pi (it’s generally quicker than waiting for the wpa tool to realise Wifi is now available). You can use commands ifdown and ifup to restart networking, but I have never had this successfully work on a Pi before. A reboot should get you working again.

Reboot with:

~# sudo reboot

The Pi should now be online (if it wasn’t already via LAN).

Update and Upgrade

Log in after the reboot, run the update and upgrade:

~# sudo apt-get update
~# sudo apt-get upgrade

The upgrade (if available) may take a while. Sit back and relax.

Install iptables rules

Linux is generally quite robust on its own, but there’s no harm in installing iptables, possibly one of the most popular and robust Firewalls for Linux.

To install, have a look at an earlier article of mine on iptables.

I have a Raspberry Pi running internally as a file server already on my network, so this next step is purely for my own use, and it allows me to quickly grab a default set of firewall rules that’s basically the same as in the article mentioned above. If you want to know more about setting up some good firewall rules on your Pi (or any Linux machine), have a search online – there’s plenty of tutorials.

~# sudo apt-get install iptables
~# cd /etc
~# wget
~# sudo iptablesrestore < /etc/iptables.rules

And you’re done!

Now you’re ready to do what you want with your Pi.


Here’s some suggestions what you could also install

Add a USB hard drive

To add a USB hard drive, plug the device into the Pi. For older Pi’s like the Pi, Pi+, or Pi 2, be sure to power off the device first – as before the Pi3, hot-plugging USB disks can sometimes cause the device to reboot. Pi3’s and better are more tolerant to the insertion of USB disks.

Once the USB disk is plugged in and the Pi is on – run the following command:

~# sudo blkid

This will allow you to get the UUID of the USB hard drive.

Add a Mount directory for the USB drive

You should create a directory to be the mount point of your new hard drive. The standard on most Linux systems is either to do this in /media or /mnt, depending on distribution.

~# sudo mkdir /media/usb_storage1

Add your USB drive to fstab

Enter the fstab file via a text editor:

~# sudo nano /etc/fstab

At the end of the file, add the following line:

UUID=”<Your drive’s UUID>” /media/usb_storage1 ext4 defaults 0 0

Note that “ext4” is the file system on the USB drive in this example – if you haven’t formatted your disk to ext4 and it loads in Windows, you want this set to “ntfs”. You may also need to check your Linux distro’s support for the Windows NTFS file format (it may support it natively or need extra libraries installed).

Install extra software as required

Install Samba

Samba provides the ability to create shared network folders that your Windows PC can see in your Network neighbourhood. This is useful if you want to move files easily between Linux and your Windows home network.

~# sudo apt-get install samba samba-common smbclient
~# sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Configure Samba

~# sudo nano /etc/samba/smb.conf

Edit the config as you see fit. There’s plenty of tutorials on-line for this.

Install MySQL

I’m still quite fond of MySQL and use it for most db-related stuff. You can install it on the Pi with:

~# sudo apt-get install mysql-server && sudo apt-get install mysql-client

Once installed, if you are allowing MySQL external access via iptables rules, make sure to edit the MySQL my.cnf file and comment out the bind_address directive, otherwise you will not be able to access MySQL remotely (even with any iptables rules in place).

Log into MySQL on the command line with:

~# mysql -uroot -p

Create a new user for remote access with:

CREATE USER ‘myuser’@’%’ IDENTIFIED BY ‘mypass’;
GRANT ALL ON *.* TO ‘myuser’@’%’;

Leave the MySQL console by typing ‘quit’.

Install Apache and PHP

~# sudo apt-get install apache2 php5 libapache2-mod-php5 && sudo apt-get install php5-gd php5-mysql php5-curl php5-intl php5-mcrypt php5-imagick

Install Source Control

Some downloads for Linux come straight from a source control system. It’s most likely going to be SVN or GIT, so it’s best to install both.

~# sudo apt-get install subversion && sudo apt-get install git

Install SOX

SOX provides useful tools for command-line sound processing. You can do things like blend audio files together on the command line.

~# sudo apt-get install sox libsox-fmt-all

Install MiniDLNA

MiniDLNA is useful for streaming video, music and photos to DLNA player devices. The project should be available in most repos, but may also be found with a newer name of ‘readymedia’. Go for whichever version is easier for you to use.

~# sudo apt-get install minidlna

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.