So you've gone and got your hands on a Rasperry Pi, and your wondering how to go about doing stuff with it. Well, I've recently done the same thing and found myself bouncing around between a lot of different websites trying to work out what the heck it's all about and how to get things working. So, I thought I'd share my findings with you.
Firstly, I suppose I'd better say I've been working as a freelance multimedia designer for years as Psicon Lab and I have some teaching experience, but my computing skills are mostly self-taught and I'm new to Linux.
I'll try to make this conversational and easy enough to understand without being too techy or specific. This isn't a set of instructions - just a conversational overview of things I've realised or encountered when starting out.
I'm assuming you've got a Raspberry Pi (model B) and a mouse, keyboard, power supply, and you've been playing around with it a bit but havn't got too far. You may be a teacher or student who's been introduced to the Pi recently but doesn't have a a great deal of experience with it.
Why should I bother with this thing?
Well, the Raspberry Pi is a tiny computer that runs a Linux operating system, and it's cheap. Linux is well supported and there's loads of free software out there for you to use, and at around £30 a pop you wont worry too much about breaking the Pi. That means you can use it as a desktop computer, access the internet, watch TV, play music & games, and build gadgets with one. Sound like fun?
So, as you probably know you need an SD card to use as your harddrive and to store your files on. First bit of advice is - use a decent size card (mine are 8GB) of as high a class as you can get (mine are Class 10) made by a good brand. I've found this makes a significant difference. This thing is your main harddrive remember, so you want it to be fast and reliable when saving and loading data.
Most people buy computers with an operating system like Windows already installed. With the Pi, you get to choose one from a selection of distributions. Distributions can vary a lot and are based on Linux which you may of heard of as it's a free alternative to Windows. The most popular distribution seems to be Raspbian, but NOOBS is a good start point as it is easy to install and has a selection of distributions you can try out easily including Rasbian (which looks and works like your usual Windows-type operating system) and BMC (a media center distribution which allows you to watch TV and play music etc.).
Formatting your SD Card
First you need to format your SD card using SDformatter to prepare it for a fresh install.
Writing the distribution to your SD Card
If your distribution is a disk image (.img file) you need to write it to the SD card using Win32DiskImager.
NOTE : NOOBS is distributed as a .zip file and you dont need Win32DiskImager to flash your SD card to get going. Simply unzip the file and copy the files onto the SD card.
Backup your SD cards
It's a really good idea to make backup copies of your SD cards which you can save on your PC and reinstall, or share with others if you want. To do this you open Win32DiskImager, choose the drive letter again, click the folder to choose a place to save your .iso file to, and then click 'Read'. This gives you a new iso file which contains everything on your Raspberry Pi's SD card including which programs were installed and any configuration settings, which is great if something goes wrong, you want to revert to an older state or you have several Pis using the same configurations.
It's worth pointing out at this stage that as your Pi's operating system resides entirely on the SD card there is nothing stopping you having a handful of SD cards all with different distributions on and swapping and changing them with a single Raspberry Pi. Useful if you have 2 SD cards, 1 pi and want to try out Raspbian and BMC for example. If you have a class of students you can setup a master disk image and just copy it to multiple SD cards and every one will be the same.
Booting up the Pi
OK, so you've got your USB keyboard and mouse connected and a monitor and put the SD card in the slot. You plug in the power adapter and if your using Raspbian you should see on your monitor lots of text appear to indicate the thing is loading.
NOTE : if you've got v1.1 of NOOBS it may just display a black screen when you start the Pi depending what monitor you have connected - if you still have a black screen after a few minutes try pressing keys 1, 2, 3 or 4. This changes the display settings (1 (HDMI), 2 (VGA), 3 (PAL) or 4 (NTSC)) and hopefully you should see a load screen.
If you ever need to login, the default user is usually 'pi' and the password 'raspberry'.
If your Pi does not boot to a desktop and you're seeing a green prompt that reads 'pi@raspberry - $' you've reached the Terminal.
The Terminal is the Linux equivalent of the Windows command prompt and allows you to start programs, make files and do anything you'd normally do with a computer by typing in commands instead of clicking icons or using the mouse. You can do lots of important stuff using the Terminal but you have to remember the commands. You will likely have to use it now and then, so don't be too scared. If your a mac user, you'll have the Linux Terminal installed on your mac, but don't get cocky - you can really bugger things up with the Terminal too. You can also get to the terminal from Rasbian's desktop as it's listed in your programs in the start menu.
Getting to the desktop
To load up the Raspbian desktop you need to type the command 'startx' into the terminal, but you can set your Pi to go straight to the desktop by changing the settings in the raspi-config.
The Raspberry Pi configuration screen allows you to set up your pi in more detail and from here you can enable different options, set your pi to boot to the desktop, change your password or overclock it. Overclocking if your not familar is a way of making your computer run faster, but is a bit risky as it can make your operating system unstable and in extreme cases damage components due to excess heat etc. so you're always warned to overclock at your own risk. The Raspberry Pi however offers up some helpful 'safer' overclocking options from 'modest' to 'turbo'. I think 'medium' is about as high as you'd want to go without knowing what your doing. If you do overclock and the pi becomes unstable, simply reset it to 'None' or a lower setting. You can type 'raspi-config' into the terminal or choose it from the start menu from the desktop.
Linux Terminal commands
As you've seen you are going to have to get to know the terminal and a few commands to get far on the Raspberry Pi, so here's the rundown on a few basics I've picked up. Note : when words in the code examples below are in italic your should replace it with something ie, a real filename or whatever.
Being a Superuser
You'll see 'sudo' appear a lot in commands, what this does is tells the Pi your want to run the command with superuser permissions. Superuser means that you can do anything (as normally certain things are not available to all users just to protect the system's files).
Always shutdown your Pi properly as files can be corrupted easily and wait for your Pi's lights to stop blinking before unplugging it.
To Shutdown the pi use
Of course, this is the same as clicking the power button from the desktop.
...or reboot it with
Some commands are shortcuts for a more complicated commands. halt and reboot are shortcuts for a command called shutdown.
In it's full form you can shutdown using
sudo shutdown -h now
or reboot with
sudo shutdown -r now
Note the -h is for halt and -r for reboot. These are called variables and tell the shutdown command to behave in a certain way. The word 'now' tells the function to happen now but it could be changed to delay the shutdown if you ever wanted. Shorthand functions do common things with less typing and fullform functions allow a bit more control.
Getting around your file system using the terminal
Once you start tinkering with your Pi you'll need to navigate around, open files and change settings using the terminal.
So, to show what folder you are currently in type
Pwd is short for 'present working directory' (A directory is what most people using Windows call a folder).
To list which files and folders are in this directory type
You can open a folder by typing
Cd is short for 'change directory', and you can go back up a level by typing
Working with Files
You can copy files on your pi by using
cp filename newfilename
Well worth doing if you are changing settings etc. and want to keep a backup of the original file.
You can move or rename files using
mv filename newfilename
To execute a program you can just type it's name in the Terminal. So for example you can open the raspi-config by typing:
or the nano text-editor by typing
All the software you install has a name although it's not always easy to find out what it is.
Editing config files with nano
A lot of the Raspberry Pi's configurations are set in files that you can edit. To open a file using the nano program you just use
sudo nano pathtofile
For example, a common command you may have seen if you've already tried to setup your network settings is
sudo nano /etc/network/interfaces
This is just telling nano to open a file called 'interfaces' in the network folder (Confusingly the file 'interfaces' has no file extension so looks like a folder name).
A couple of tips...
- If you forget to write 'sudo' for a command and are dreading typing it all in again, just type 'sudo !!' and it will run the previous command again but as a superuser.
- If you want to reuse a command you typed recently, you can press the up and down arrow keys to insert recently typed commands. Warning - if you press these keys thinking they will scroll the page you may well have this happen by accident!