Table of Contents

Meet The Raspberry Pi

    Another fruity computer

    The Raspberry Pi Foundation

    The intended audience

    What you can do with it

Raspberry Pi Hardware

    The first encounter

    Flavors of Pi

    How ARM architecture is different from x86

    A word about memory

    Connecting external storage

    Features not found in Pi

    Additional components needed

    The supply of power

    The case for a case

Setting Up The Pi

    Connect a keyboard and mouse

    Decide on a display

    Operating system choices

    Why Raspbian?

    Prepare a bootable SD card

    Flash the SD card

Start The Pi For The First Time

    Boot into the Pi

    Command promoting through LXTerminal

    Customize your installation with Raspi-config

    Expand the Filesystem

    Configure your keyboard

    Set time, date and time zone

    About user accounts

    Go online

Find Your Way Through Raspbian

    Shell shocked

    Start the desktop

    Manage processes

    The power of sudo

    Shutdown and reboot

Call In The Software

    Using package managers

    Finding software with apt

    Install and remove software

    Upgrading software

    The Pi Store

Configuring The Pi

    The configuration files

    Update the kernel

    Adjusting available memory

    Tuning the video output

    Turn your Pi into a Kiosk

Networking With Pi

    The Midori web browser

    Install Chromium

    Use Secure Shell

    Share your Pi desktop with your computer

    Serving Pi

Multimedia Pi

    Use XBMC to turn your Raspberry Pi into a multimedia center

    Bring Raspbmc into the picture

    Controlling XBMC remotely

    Streaming Internet media

Pi Productivity

    What’s on offer?

    Suite it up with OpenOffice.org

    Image editing with The Gimp

    Cloud services to the rescue

Time For Some Pi Gaming

    Emulating other platforms

    Native games

    Genres on offer

Next Steps

    Programming with Scratch

    Python on the Pi

    Build and control small electronic devices using GPIO ports

Troubleshooting And Overclocking

    Fix common problems

    Overclocking the Raspberry Pi

Resources

    List of online resources

Legal Stuff

Meet The Raspberry Pi

While it may sound more like a delicacy, the Raspberry Pi is, in fact, a computer — one that promises a world of interesting and intriguing possibilities. If you are reading this, chances are that you may already know this much. Maybe you heard about the Pi from a friend, or read about it on the web, in a book or a magazine. But for the uninitiated, the Raspberry Pi is a small computer, about the size of a credit card, which comes at a sweet, sweet price of $35.

Another fruity computer

The Raspberry Pi gets the first half of its name from the classic tradition of using fruit to name computer systems. Vintage systems like Acorn, Apricot and Tangerine to newer brands like Apple and Blackberry all get their names courtesy of fruits. The second half of the Raspberry Pi, however, comes from the Python programming language that holds special significance for this highly affordable system, as you will soon find out in the chapters that follow.

Needless to say, people were skeptical when this device was first announced. But when it started shipping it created a frenzy of excitement. No matter how you look at Raspberry Pi, the imperative thing that you will come back to is the price. Anything and everything this device promises is interesting primarily because of the extremely affordable price of the Pi. Pretty much anyone can pick up a Raspberry Pi without having to think too much about it. The same cannot be said of laptops, with even the most modest ones at least ten times more expensive than the Pi.

The Raspberry Pi Foundation

The groups of people that worked on and brought to us the Raspberry Pi are united under the umbrella of the Raspberry Pi Foundation. This non-profit charity, and the community that it has sprung, is the reason why we are here, why you are interested in this device, and why you are reading this book. The Foundation has solicited the support of two distributers to produce and sell the Raspberry Pi — Farnell and RS Components.

Founded in 2009 with the aim of rekindling the development spirit that was so prevalent in computing back in the 80s, the Raspberry Pi Foundation oversees the provision of this affordable platform so that young people all over the world can dive into the wonderful world of home computing in a meaningful way. It is headquartered in Caldecote, Cambridgeshire, UK. You can visit the official website of the Raspberry Pi Foundation to find out more about this organization.

The intended audience

Originally developed by the Raspberry Pi Foundation to teach children how to program, the Pi soon generated a wave of enthusiasm amongst the computing community. So high was the demand that it outstripped supply for many a months. Things have improved manifolds as of this writing, but even now the waitlists for these small computers are very long.

The intended audience can broadly be classified into two categories — the first is made up of technology enthusiasts who are proficient at Linux and want a smaller yet powerful server. Sure the fact that it is a cheap one is an icing on a very impressive cake. There are PCs available on the market that require very low-power, but again, they are not nearly as affordable as the Pi.

Now, the second category is for those people who like the idea of a nifty little computer for $35 that they can do some impressive stuff with, experiment and see how they can put it to use. And this is where a lot of the fun lies. You can tinker and tamper with a Pi without any guilt of a major monetary loss and try all sorts of interesting things on it.

What you can do with it

To be quite honest, the Raspberry Pi can do a lot of things very respectfully. It is probably not going to replace your main home PC — but again a Pi is not going to break the bank either. Since the Pi is terrifically close to a normal PC, even though it is built on a different architecture (more on this later) you can do a lot of stuff on it that you would normally associate with a personal computer.

And this means that you will not have to start from scratch to get to grips with all the amazing possibilities Pi has to offer. Most of what you already know can be applied to your Pi. Starting off, you will want to do a lot of things other Pi pioneers tried (and accomplished) on their Raspberry Pi devices. By the time you are done reading this book, you will have a clear idea of how to do a lot of essential stuff, and where to go looking when you want more interesting adventures.

Perhaps the absolute best thing about the Raspberry Pi is that there is no single set way to use it. This multi-purpose machine can be used to watch high-definition videos or surf the web as easily as it can be set up to act as a server. Its greatest strength lies in the fact that it is a flexible platform — one that is built not just for fun and utility but experimentation and examination. Here is just a slender selection of the different ways you can use your Raspberry Pi:

General purpose everyday computing

Playing classic games

Web browsing

Media center

Learning to program

Integration with technology projects

Advanced coding for the Pi platform itself

With affordable and small devices like the Raspberry Pi, a completely new era of computing is dawning upon us — one that you can be a part of. And this book will help you get up to speed quickly. As you go through each chapter you will gain an insight and understanding of the real strengths of the Raspberry Pi and how it can become a useful tool in your digital life.

Raspberry Pi Hardware

As of right now only two distributors produce and sell the Raspberry Pi — Farnell and RS Components. Both retailers have online stores and also sell additional accessories for it. You can buy anything from a power supply to a keyboard, mouse, casing and more. There is a growing list of compatible hardware for the Pi, but it is always a good idea to buy hardware from official resellers, just to be on the safe side.

The first encounter

Before you start your Raspberry Pi for the first time, it is a good idea to familiarize yourself with the nitty-gritty, nuts and bolts, the connectors and capabilities of the hardware. This will help you to not only understand what kind of projects you can use your Pi for, but also define and describe any additional hardware you will need. Additional hardware includes stuff like a power supply, a keyboard, a mouse and, of course, a display.

Unboxing the Pi is a no-frills affair. The Raspberry Pi usually arrives in a plain cardboard box with a couple of sheets of paper that contain the usual safety procedures and a quick-start guide. Currently, the Pi looks like something out of a computer geek’s dream — a utilitarian single-board computer, about the size of a credit card that actually resembles the insides of electronic devices. Maybe in the future, a Raspberry Pi will ship with a case, but for now it is the inside that matters.

Flavors of Pi

Before we get any further, a word about the two available models of Raspberry Pi. The $35 price tag is something that is talked about a fair bit in this ebook, and understandably it is one of the most distinctive features of the Pi. But there is another, even more affordable model available that retails for an even sweeter price of $25.

If you thought both models would be inspiringly named, then prepare for a bit of a disappointment. The two versions of Pi are known as Model A and Model B. There is not too much of a difference between the two models, with Model B the bit more expensive (and a lot more prevalent) of the two. The extra $10 gives Model B a couple of extra ports that are built into the device —a 10/100 Ethernet port and an additional USB port. And well, owing to these factors, the Model B also draws just a little more power.

So which one should you get? If networking is on your mind and you plan to connect your Pi to a LAN, then the built-in Ethernet port is downright essential. Ethernet connectivity just makes life so much easier. But if this is something that you are not planning then Model A may be your best bet. The difference between both is so small, however, that it might be worth spending an extra $10 just in case you want to bring networking into the picture later down the road.

How ARM architecture is different from x86

If there is one defining difference between the Raspberry Pi and a typical PC it is the architecture employed. Traditional desktop and laptop computers make use of the x86 (and its 64-bit variant, x64) architecture, made popular by the likes of Intel and AMD. The Pi, on the other hand, is designed to run on a version of instruction set architecture known by the name of ARM. This was developed by Acorn Computers back in the late 80s, but is an uncommon sight in the desktop world. Mobile devices like tablets and smartphones, however, is where it has found colossal success, thanks to its low-power requirements and even lower prices.

The processor that beats in the center of the Raspberry Pi system is the Broadcom BCM2835. It is a SoC (system-on-chip) multimedia processor. What this means is that almost all of the essential system components like graphics, audio and communications hardware, along with the central processing is housed inside the processor. All this is built into this single component that is located beneath the 256 MB memory chip at the center of the board.

This ARM-based processor is the secret mojo of the Raspberry Pi, and the reason why it is able to operate with just the (5V 1A) power that is provided by its onboard microUSB port. It is also why the device does away with a heatsink — the low power means the device generates nominal heat, even during processor intensive tasks.

And as you may have guessed, the architectural differences mean that the operating system (and consequently the choice of software applications) is also different for the Pi. It runs flavors of Linux instead of Windows or Apple OS X. But as you will discover in later chapters of this book, there are plenty of software available for the particular ARM architecture used on the Pi, and this is a list that only continues to grow as the Raspberry Pi finds more and more acceptance.

A word about memory

Starting October 2012, the Model B of Pi now comes with 512MB of RAM (up from 256 MB), and this memory is shared between the system and the GPU (graphics processing unit). You may be asking, wait, what, isn’t that still a bit on the low side? With most traditional PCs are now enjoying 8GB of memory it does indeed sound a little weak.

But the answer to this is that the 512MB is quite enough for most tasks, particularly on Linux. It may not seem like much, but then again, back in the days, Windows 95 used to perform adequately with only 8MB of RAM. Older computers came with even less, the good old Commodore had to make do with a mere 64KB — and it was able to run a variety of stuff.

Connecting external storage

External storage is an absolute necessity on the Raspberry Pi. As you may have noticed, it does not have a traditional hard drive. Instead it is uses a Secure Digital (SD) card, the ones typically used in digital cameras. Most any sized SD card will work with the Pi, but since it is supposed to hold the entire operating system, it is a good idea to have one with at least 2GB in capacity to store all the files.

Since it comes with no BIOS, the Pi always boots from an SD card, even if you have a valid operating system installed on a USB stick or external hard drive. Sure, external storage devices can be used perfectly fine with the Pi — they just cannot be used for booting purposes.

Features not found in Pi

While it would have been great seeing the world and everything in it on a Raspberry Pi, the fact remains that there are a number of essential features that you would associate with most modern computers that are not found in the Pi. In many ways this is understandable, taking the cheap price into account, but things like a real-time clock (RTC) with a backup battery found on other computers is missing. Same can be said for a Basic Input Output System (BIOS) that most PC users will be accustomed to.

The Pi also does not support Bluetooth or WiFi out of the box — though both these features can be added in using USB dongles. What this means is that you will have to make sure that your chosen flavor of Linux supports a particular device. For better or for worse, most Linux distributions are still fussy about their hardware. Nevertheless, while it is not all that difficult to work around some of these missing features, the lack of the BIOS can be seen as a tad more severe omission.

Additional components needed

When you unbox your Pi for the first time, it will hit you — this is a ‘Bring your own peripherals’ party. The board is the only thing in the box, and you will need a few things to get everything up and running. But the good news is that most of the stuff you probably already have at home. To enjoy your Pi in perfection, here is a list of the necessary components:

microUSB cable (for power)

USB power adaptor (again, for power)

HDMI cable

HDMI display

SD card (anything from 2 GB to 64 GB, 8 GB minimum recommended)

SD card reader

USB keyboard and mouse

Ethernet cable (or a wireless USB dongle)

The supply of power

The first order of business is a power supply that comes with a microUSB connector. Pi does not currently ship with one. Both Pi models need a power supply that can output 5V. How much power it should source depends upon how many devices you have connected — but at a minimum, the power supply should be able to source 300mA for Model A and 700mA for Model B.

Nevertheless, it makes sense to actually aim for an adaptor that can supply at least 1000 ma (1 amp, actually). The good news is that most smartphone (and even some regular cellphone) chargers meet this requirement. But if not, you can easily pay your local electronic shop a visit and get one. The bad news in the power department is that no external device should draw more than 100mA from any of its USB ports. Meaning as long as your external keyboards and mice work under this radar, they are in the clear.

The case for a case

Once you start using your Raspberry Pi, you will quickly feel the need for a case for the Pi. As mentioned earlier, future releases of Pi may came with a case, but for now, you will have to protect it yourself. Like all electronic devices, the Raspberry Pi is sensitive to dust making a case an absolute necessity, sooner rather than later. You can buy professional cases that offer convenient access to the connectors on the Pi from online stores like Adafruit, ModMyPi and more.

Now that you have a bit of an idea how the Raspberry Pi differs from other computers in the market, it is time to get the party started. But just before you begin your adventure, you will need to take care of two important factors, namely input and output.

Setting Up The Pi

The plot thickens. You learned the basics of the Pi hardware, the connectors and components, and additional devices in the previous chapter. Now is the time learn what you need to start the Pi for the first time, set up input and output peripherals, and how to prepare a SD card by loading an operating system onto it.

Connect a keyboard and mouse

There are some of you that may want to use the Pi as a headless system (meaning one without input and output attached), but for most others connecting a keyboard and mouse is the first order of business. You may already have a spare keyboard and mouse at home — just make sure they have a USB connector, and ideally consume only 100mA each.

Some wireless keyboards and mice may not work properly, however. And this is usually the case because they may be incompatible with Linux. A wired option in this instance is not a bad idea. Plus there may be times when you will need more than two USB devices (in case of Model A, more than one). For this you can connect all of them to the Pi using a USB hub. Again, make sure the hub delivers enough current to power all devices that you connect through it.

Decide on a display

You probably saw this coming already, but just like a traditional PC, a display is an absolute necessity for the Pi. What connectivity you use for a display device depends on the type of display you are using, but in most cases the choice will come down to either an HDMI cable or a composite video cable.

Since HDMI cables also carry audio, all you need is your display device to support audio and you are done. If not, then connect the audio jack of the Pi to your sound system using a standard cable with 3.5mm TRS connector. This is the universally famous connector found at the end of most headphones, speaking of which, yes, you can also use your headphones to listen to the audio.

Operating system choices

If you own a traditional computer, chances are that it is being powered by an operating system — usually a version of Windows, OS X or a variant of Linux. An OS (short for operating system) is what starts up when you turn on your computer. Both Windows and OS X are closed source solutions developed by Microsoft and Apple respectively. Windows has only just started supporting ARM devices with Windows RT, but again, that operating system is not developed with the Raspberry Pi in mind, and will not run on it. In fact, it is not even available for purchase and only comes embedded with devices.

What will run on the Raspberry Pi is GNU/Linux — or Linux for short. The open source nature of Linux meant that it was readily developed to run on all sorts of devices powered by ARM processors. And unlike the other two operating systems mentioned above, Linux is open continually developed and maintained by vibrant community. Plus the open source nature of it means that it is possible to download the source code for the entire operating system and make whatever changes one desires. And many adventurous users (and organizations) have done exactly this.

There are several variants of Linux, known as distributions that have been ported to run on Pi. These include names like Debian, Fedora Remix and Arch Linux. There are some exclusive flavors for Pi, but hundreds of different distributions of Linux are available for desktop, laptop and mobile devices owing to the widespread success of traditional PCs. Nevertheless, the important thing is that while each distribution is developed to cater to different needs, all are free and open source, and you are free to choose either one for your Pi. Most decide to go with Raspbian — a distribution based on Debian.

Why Raspbian?

So then, the $16 million dollar question is which distribution is best? The answer to this is that it depends on your needs — there is no perfect distribution. For the Raspberry Pi, the official and supported platform is Raspbian, which itself is based on the immensely popular Debian distribution. Not only is it officially supported, it is also the easiest to use and as the Pi community grows, the fastest to get updates and fix specific for the Raspberry Pi. For these reasons, choosing Raspbian is a no-brainer.

If you are more adventurous, and fancy doing something a little different you can try your hands with other Linux distribution for the Pi. In this book, however, we will be focusing on Raspbian. You can point your browser to www.raspberrypi.org/downloads/ to get your hand on the latest version of Raspbian. The download page not only contains links to this operating system image itself, but also other prebaked Linux distributions for the Raspberry Pi, along with a number of useful tools.

Prepare a bootable SD card

Now is the time to get Raspbian onto your SD card. For better or for worse, this is not as easy as simply copying across the image file. Think of it this way, if you copy the downloaded image onto the card, it will be just that — a SD card with a copy of the Raspbian image on it. What we need to do is write the image directly onto the card, and this calls for some ingenuity and a couple of tools.

The idea with images is that for all essential purposes, they are clones of the real thing — the real thing in this case being the master copy of the operating system disc. Once you write the image to a CD or DVD, it will be a perfectly cloned copy of the original disc. But since the Pi does not come with a CDROM or optical disc drive, we are going to download the image and put it on a SD card that will contain the Raspbian all set up, ready and raring to be used.

Flash the SD card

For some people SD cards that come with an operating system preinstalled may be the best option. Many vendors sell cards like these. And even the OS on the card is not the latest version, it is easily upgradable once you boot up Pi and connect it to the Internet. Those of you who want to flash the SD card personally will need a card reader (some PCs come with these built-in, but any inexpensive one will do fine) and a disk image utility, most of which can be downloaded for free on the Internet.

The instructions vary depending on the operating system you are running like Windows, OS X, or Linux. Although it is not necessary, it is always a good idea to check the integrity of the file you have downloaded. You can do this by confirming the hexadecimal checksum of the Raspbian image. If the number is the same on the download page, then proceed. Otherwise download the image from another location to make sure you are not flashing a compromised or affected image.

No matter which operating system you have used to flash, you should have a bootable SD card containing Raspbian Linux. Next step is to start the operating system on the Pi for the first time.

Start The Pi For The First Time

One of the universal truths in the field of computing is that no operating system or hardware fits everybody’s needs right out of the box. Users will always want to customize their installation. This is particularly true for the Raspberry Pi because Raspbian comes as an image, meaning you cannot choose all the configuration parameters right, away as you would on a traditional desktop operating system.

Boot into the Pi

While unboxing the hardware and preparing an operating system are important, the real fun lies in the first time you actually boot into it. The fun doubles when you do so the first time. Booting into the Raspberry Pi for the first time is just as exciting, as you start up the installation and see what the operating system is capable of. So without further ado, let’s get down to the business. Insert the SD card that you have flashed with the Raspbian image and plug in the power supply and then wait and see as your Pi starts up for the first time.

Command promoting through LXTerminal

One of the more interesting elements of Linux, and one where you will spend a lot of time in, is the command prompt. The command prompt is not much different from the terminals that are available in Windows and OS X. On Raspbian, it is called LXTerminal. There is one small change, however. The home directory has a shorthand notation that is displayed as a tilde symbol. You get a display of the current directory before the command prompt. Once you fire up LXTerminal, you will be dropped into your home directory, and the prompt will look something like this:

pi@raspberry ~ $

Here ‘pi’ is the username, which is followed by the ‘@’ symbol. The name of the computer comes next, in this case ‘raspberry’ being the default hostname. The current working directory is denoted by the tilde symbol since you always start out in the home directory. And finally the shell prompt starts. Any text you type here will appear to the right of the ($) sign. Just hit the Enter key to execute each command as you type it.

Customize your installation with Raspi-config

The first time you boot into Raspbian, it will start a configuration program by the name of Raspi-config. As the name gives away, this helps you configure the important aspects of the Linux operating system. It actually makes most configuration tasks a breeze, thanks to its centralized panel. Raspi-config will not automatically start the next time you boot into Pi, though you can easily invoke it in a terminal by typing:

sudo raspi-config

Most of you are probably used to managing user interfaces with your mouse, but Raspi-config has to be controlled with the keyboard. Just use your up and down cursor keys to move between menu items. The right arrow or Tab keys select the menu item, and once the Select button at the bottom is highlighted, you can press the Spacebar or Return key to enter. We will take a look at some of the most important menu items in this configuration utility, but the good thing is that most offer detailed descriptions so learning what most Raspi-config options are for is a snap.

Expand the Filesystem

Perhaps the most essential item is the expand_rootfs option, which as the description suggests expands the filesystem to fill the entire card. The Raspbian installation should currently be taking about 2GB of space on the SD card, and that is because the image you downloaded and decompressed came in at this size. But even if you have an 8GB SD card (or larger), you will still only be able to see the first 2GB of it because this is the current limit. The reason for this is that the filesystem is not yet expanded.

If you do not do this, you will need to set up different image files for each disk size. But if you do, then you can take advantage of all the space we have available on the card using that same small image and expanding it. To do so, use your arrow keys to highlight the option and press Enter. A window should tell you that the partition has been resized, and the filesystem will also be resized the next time you restart. Hit the enter key to go back to the main menu.

Configure your keyboard

The next order of business is configuring the keyboard. This can be done using the configure_keyboard option. By default Raspbian assumes that you are using an English keyboard layout, and this may lead to some confusion if you are not. This configuration option first asks for the type of keyboard you are currently using. Next you will have to specify the language you are using, and finally configure the behavior of a few special keys.

Set time, date and time zone

As mentioned in the second chapter, in an effort to reduce cost, the Pi does not come with a real-time clock. What this means is that it does not store the current date and time internally. This makes setting the correct date and time critically important for many purposes (like validating encrypted certificates when browsing the web).

When it boots, Raspbian actually contacts a time server on the Internet and sets the current time and date automatically and accurately. What it does not know is your time zone. This is where the change_timezone menu item in Raspi-config comes into play. Select it and it will ask a few questions to determine where you live. It will then store your time zone information in your profile, so the next time you boot your Pi, it will remember what time zone you live in.

About user accounts

Like Windows and OS X, Linux is also designed to accommodate numerous users. By default Raspbian is configured with two user accounts, pi (which is the normal user account) and root (which is the administrator or superuser account with additional permissions). You can definitely use the pi account, but your own dedicated user account can also be easily created. For the sake of simplicity in this book, however, we will be using the default user, pi.

Same goes for friends and family — new accounts can also be created for your associates that want to use the Pi. It is a good idea to use a non-privileged user account instead of root, as that protects against accidently causing havoc to the operating system, and from the chaos that comes with virus and other malware that come through the Internet. Speaking of which, it is about time to go online.

Go online

The thing with Linux is that it is best experienced connected to the web. The same holds true for the Pi. There are a number of different ways to connect to the Internet. If you have got access to a router (or switch) you can just plug it in using a standard Ethernet cable. You can also get online wirelessly using a WiFi USB dongle, however keep in mind not all wireless dongles work with Pi, so be sure to select a supported one.

Pi can also be connected to the Internet via WiFi sharing if you have got a laptop nearby. This can be done easily on Windows by enabling the ‘Allow other network users to connect through this computer’s Internet connection’ option. On OS X this can be set up by enabling Internet sharing in the Settings, and then connecting the Pi with the Mac. Once connected, the Pi should automatically be assigned an IP address and will be online.

So then, after configuring some essential options, it is now time to reboot the Pi and finally start using it. Hit the Tab key twice to highlight the Finish button and press Enter. This will shut down your Pi and reboot it. If you expanded the root filesystem, this is when you will see it during the boot process. The process of expanding will take a while depending on the size of your SD card. It is now when you will arrive at a pretty little graphical display — the desktop.

Find Your Way Through Raspbian

Almost all popular Linux distributions have one thing going for them. They are immensely user friendly and offer support for a graphical user interface (GUI) which provides users with an easy way to perform most of the tasks. And better yet, the majority of them are quite similar to Windows and OS X. But to get most out of the Pi, you need to have a good grip of using the operating system, so here is a whirlwind primer in using Raspbian.

Shell shocked

Unlike Windows, Linux at its core is not integrated with a particular GUI. Think of the graphical interface as a special layer on top of the operating system. The terminal is the king of the hill in this world — no doubt a throwback to the age of the UNIX operating system, on which Linux is based. Instead it uses a separate application to provide a visual shell. Raspbian comes with a graphical desktop environment already installed. It goes by the name of Lightweight X11 Desktop Environment (LXDE). Since the Raspberry Pi offers modest computational power, it stands to reason that you deploy a lightweight environment for a comfortably fast experience.

The thing with GUIs and desktop environments in Linux is that like everything else in the Linux world you have a myriad of choices. While most users will stick with the default one that comes with their distribution, there are more advanced solutions available, complete with added bells and whistles. This is not a problem on desktops and laptops — the special effects and flashy features work quite well on these powerful machines.

But this becomes a bit of a concern on a machine with lower specifications like the Raspberry Pi. For this reason the LXDE is perfect. The LXDE was actually designed for machines that require greater energy efficiency and need to run on lower end hardware. Here performance is critically more important than the glass and gloss. While some environments steer absolutely clear of all unnecessary features, LXDE nevertheless tries to maintain a balance, and offers a full set of features whenever possible.

Although the majority of this book will focus on getting you comfortable with the command line interface of the Pi, and really digging into the Linux operating system, you will be spending a lot of time in the graphical interface that comes with Raspbian. In many ways, LXDE will be the main environment for your Pi, and will make up a core part of your Raspberry Pi adventure.

Start the desktop

It may be essential to other operating systems, but as noted above, a desktop environment is optional on Linux. What this means is that you will often have to start it manually. For Raspbian, however, the graphical desktop environment is set to automatically start.  There is a way to start the desktop environment automatically whenever Pi boots by setting the option in the Raspi-config tool menu.

You can also start the graphical user interface of the desktop manually by typing:

pi@raspberry ~ $ startx

Soon you will be treated to the familiar desktop environment, not overly different from the one that is bundled with the Windows operating system. There is even a Start menu that contains all the important programs and items in it. The desktop system ships with a terminal emulator that you can use to type in commands directly, there is even a shortcut to the LXTerminal. With the acquainted and familiar look and feel of the graphical desktop, you should be off and running in no time!

Manage processes

Every time a command is run or an application is started on a Linux system, the kernel of the operating system starts a new process. The Task Manager in the System Tools of the Start Menu in LXDE lists all the processes that are currently running on your machine, along with how much system resource each one is using. You can also list your current processes in the terminal with the ps command. Here:

pi@raspberry ~ $ ps

This will generate a list of all running processes, with their process IDs. Add -f to the command to get even more detailed information about the processes, or -ef to see information about every single Linux service that has been started by Pi. There may be instances where you may want to kill off a process if it becomes unresponsive or starts taking up too many resources. To do so find the ID and type:

pi@raspberry ~ $ kill 9211

This will stop the process with the ID 9211. In case of system processes, you will not have permission to kill it, and here is where the power of sudo comes into play.

The power of sudo

As mentioned earlier, Linux is a multiuser operating system. What this means is that everyone is master of their own domain — each user owns its files, can create, modify and delete them within their own space in the filesystem. The root (or superuser) has the power to modify any file in the operating system, and as you would imagine, this does not come without risk.

A regular user cannot cause much potential damage, but a superuser can accidently (or otherwise) wreak havoc on the operating system, particularly when moving or deleting files. And this is why it is not a good idea to log in as the root user for everyday tasks. Sure if things go bad, you can always make a new SD card image. But there are tools that allow anyone to act like a superuser for performing tasks like installing and managing software — without the dangers and responsibilities of being logged in as root.

One such tool is sudo, which allows the ability to interact with the Pi hardware directly, or change system configurations. This is put to particularly good use when installing software packages onto your Raspberry Pi as you will see in the next chapter.

Shutdown and reboot

As you may have guessed, there is no power button on the Raspberry Pi. This means that the proper way to shutdown is through the Logout menu on the graphical desktop. Select Shutdown to, well, halt the system. Make sure you do a clean shutdown, and not simply switch off the Pi. Switching off may result in loss of data. You can also shut down the Pi with the following command:

sudo shutdown -h now

And to reboot the Raspberry Pi, use the following:

sudo reboot

You have now learned the absolute basics of the Raspbian operating system, along with how the LXDE graphical user interface works. How much time you spend on the desktop or the terminal will be dictated by your experience with Linux — whether you are a novice or power user. Now is the time to look for new software, now is the time to call in the cavalry.

Call In The Software

If there is one area where Linux absolutely overwhelms other operating systems, it is in software management. Sure, being a community-driven open source OS helps in no small amount, but on Linux, the downloading and installation of software is automatically handled by package mangers. Raspbian actually comes with a minimum set of applications, meaning you will want to download and install new programs soon after installation.

Using package managers

Packages are what Linux calls pieces of software. These include individual applications or a collection of different pieces of software designed to work together. The package managers on Linux are extraordinarily robust. The reason for this is that keeping with the modular approach of the operating system itself, many Linux applications depend on other pieces of software. Package managers keep it straight by handling all this effortlessly.

Raspbian comes with a tool that goes by the name of apt. This is a powerful package manager that is designed to be operated from the command line. But do not worry, it is intuitively user friendly and you can get a hang of it easily. Alternatively, you can use a GUI for it — the most popular of these is Synaptic Package Manager. But the thing with these graphical managers is that they often struggle to run on the Pi, because of the lack of available memory. For this reason software is best installed using the terminal.

Oh, and as is usually the case with Linux, there are a number of alternative package managers available for it. Raspbian (and by the same token, Debian) comes with apt, but other distributions use other tools. Fedora Remix for example uses the pacman tool. Other distributions use the yum package manager. These alternates are no more difficult to use than apt, but their syntax is obviously different — meaning you will have to type different commands to install or remove software.

Anyway, long story short, a package manager not only keeps track of all the software that is installed on the system, it also manages it, keeps tabs on everything that is currently set up, installs updates as they become available, and also allows for the removal of old software. They are called package managers, for a reason, after all!

Finding software with apt

The default software that comes with Raspbian is enough to get you started, but you are going to want to install new programs soon. Finding new software for your Pi is simple. The first order of business before you install a new program is to find out what it is called. And the easiest way to do this is to search the cache of available software packages. Internet servers (more like repositories) keep a list of all software available to be installed via apt.

The apt tool comes with a utility for managing this cached list of software, called apt-cache. This can be used to run a search on any and all available software packages for a particular word or phrase. For instance, if you want to find a game to play, just type the following command:

apt-cache search game

This will present you with a list of games. And as you would expect, this particular search term brings up a million different (okay, I may have exaggerated a bit here) packages, which makes it impossible to see all of them on a single screen display. To get past this, tell Linux to pause on each screen by piping the output of apt-cache through a simple tool called less. Simply change the command to this:

apt-cache search game | less

Now you will get the list of games one screen at a time. Just use the cursor keys to scroll through the list, and press the Q key on the keyboard to exit.

Having said that, before you get down to the business of installing new software (or upgrading existing applications) you will need to make sure the apt cache itself is up to date. You can do this by simply typing this command:

sudo apt-get update

Though as mentioned above, some packages rely on other packages in order to operate. For example, a programming language may depend on a compiler to be installed, an audio player may need codecs to play back different formats, or a game may require additional graphic files. In technical Linux terms, these are known as dependencies.

Dependencies are the biggest reason why you should use a package manager like apt to install software rather than doing so manually — because if a package depends on other packages, apt will automatically find them for you and prepare them for installation. When this happens, you will be shown a prompt asking whether you want to continue. Just type the Y key to answer yes and press Enter.

Install and remove software

Once you have the name of the package you want to install, it is time to get down to the business of download and setup. On Linux Installing software is a privilege that is only given to the root users. This is because it affects all other users on the Pi. So the command has to start off with the preface sudo to let the operating system know that it should be run as the root users.

For example you want to install tome (a single-player, text-based, dungeon simulation game), and to do so you would simply use the install command with apt-get like this and see the magic:

sudo apt-get install tome

In the case you do not want a particular piece of software, uninstalling it is as easy as breeze. The apt-get tool also includes a remove command that cleanly uninstalls the package (along with any dependencies that are no longer required). For example, to remove tome, simply open the terminal and type the following command and it will begin uninstalling:

sudo apt-get remove tome

If you want a bit more aggressive solution, the purge command is the more powerful incarnation of remove. Just like remove, purge gets rid of the software that you no longer require. But while the remove command leaves the configuration settings of that particular software intact, purge actually takes no prisoners and removes everything. If you have messed up a package and it no longer works, then purge is your new friend. Type this to see some action:

sudo apt-get purge tome

Upgrading software

Along with installing and uninstalling software packages, apt can also be used to keep them up to date. Upgrading a package through apt ensures that you receive the latest version of the software, with bug fixes and security patches. But before you try to upgrade a package, make sure that the apt cache is as fresh as possible by running an update:

sudo apt-get update

Updating the packages can be accomplished in two ways — either upgrading everything on your Pi at once or individually updating each program. If you want to keep your complete distribution upgraded, then type the following:

sudo apt-get upgrade

But if you want to upgrade a specific program, a specific package, then simply tell apt to install it again. Once again, going back to our example, if you want to upgrade tome, type:

sudo apt-get install tome

Since we have already installed tome, apt will treat this as an upgrade. If the latest version of the game is already installed, it will tell you that it cannot upgrade the software and exit.

The Pi Store

In late 2012 (December 17 to be exact) the Raspberry Pi Foundation opened the Pi Store. This application repository is what the foundation calls a one stop shop for all Raspberry Pi software needs. Additionally a dedicated application allows users to browse through all the different categories and then download whatever they want.

The Pi Store also allows the option of uploading software, which is made available for release after moderation. The app store launched with 23 free titles under, from utilities to productivity applications and games, but has since then added a number of additional applications, most of which are free. The official website of the Pi Store also includes an option to downloading the official client, which can then be used to download the apps.

Configuring The Pi

The Pi hardware finds it origins in embedded computing, and it is for this reason that the Raspberry Pi does not have anything that resembles a BIOS menu that is so prevalent in modern computers. Instead it has to rely on text files that contain configuration settings, and these are loaded by the chip whenever the Pi is powered on. We will take a short and swift tour of some of the most important options, but do bear in mind that changing some of these settings from the defaults can potentially result in a Pi that does not boot or even physically damage the system. In other words, tread with caution.

The configuration files

All the important parameters for the Pi firmware are stored in text files, and they can be easily used to tweak settings like video, audio or even changing the CPU clock rate. Most of the customization options can be found in these three files — config.txt, cmdline.txt and start.elf. All are located in the /boot directory of your installation. The config.txt file actually controls almost all aspects of the Pi’s hardware (save for memory allocation between the CPU and GPU), and is only read when the system first starts up. Meaning any changes made while the Pi is running will not take effect until the system is restarted.

While at first glance the configuration parameters may seem a tad overwhelming, they are anything but. Most configuration parameters on Linux have a simple format — they start with a name followed by an equal sign and then a value. Comments can be added (and usually are) and they start with the # character. As said above, any revisions or changes you make to the configuration files, once saved, will be reflected the next time you boot up the Pi. Meaning you have to reboot your Pi every time you change the config.txt file, so getting the settings just right sometimes takes a while.

If you get an error, and your Pi does not start any longer, or the display turns out wrong, then the fix is as simple as it get. Just edit the config.txt file on a separate PC, revert the changes, and plug the SD card back in. And in case you are completely lost, simply delete the config.txt file and the Pi will start with its defaults. And sure enough, you can also copy a fresh Raspbian image onto the SD card, if you want. Only the advanced options like overclocking or overvoltage can damage your device.

Update the kernel

The kernel is the core, the very heart of the operating system. It manages all processes and hardware on the Pi, and all software applications depend upon it to function. Raspbian already comes with a firmware for the Pi, but the developers of the Linux kernel release frequent updates, which usually contain bug fixes and improvements. For this reason it makes sense to update both the kernel and the firmware from time to time. You can check the versions of the kernel and firmware using the following commands in the terminal:

pi@raspberry ~ $ uname –a

pi@raspberry ~ $ /opt/vc/bin/vcgencmd version

Doing so will display the version number and date when the installer kernel and firmware were updated. To download new versions, you will have to head over to GitHub where the latest versions of each are listed. All you have to do then is to download them and copy them onto the SD card. Installing a new kernel or firmware update for your Pi is as easy as replacing a few files in the /boot directory of the Pi. The best bit is that this directory belongs to the boot partition of the SD card, and is formatted with the universally accepted FAT file system. What this means is that you can easily read and write files in this directory not just from your Pi, but pretty much every computer in the world.

The firmware is contained in the start.elf file, and the kernel in the kernel.img file. The files that start with the word arm also contain the firmware images, but they come with different memory configurations (which you will learn in just a bit). All you have to do now is download the new kernel and firmware files on a regular PC and then copy them onto the SD card using a card reader. Additionally, there is also another solution by the name of Rpi-Update that can automate this whole process for you. Once your Pi gets a new firmware, you will have to reboot the device to activate it.

Adjusting available memory

While the latest model of the Raspberry Pi has increased the amount of RAM to 512MB from the 256MB in the original, it is still a far cry from what desktops, laptops, even most midrange smartphones pack in. And not just that, the available memory is split and shared between the CPU and GPU. By default, the central processor gets the higher amount of memory to itself, while the graphics processing unit makes do with a smaller slice.

This is reasonable enough for most cases. But in some usage scenarios a different set up might make sense. For example, if you use your Pi as a server, you will surely want to assign as much memory as possible to the CPU, as there will not be too much of a need for graphics power. In this case some slight adjustments to the memory layout are in order. But before we get to that, type the following command in the terminal to get an idea of the memory situation on your Pi:

pi@raspberry ~ $ free -m

The memory split on the Raspberry Pi is controlled by a file called start.elf. The default split is decided by those who maintain a particular Linux distribution. Some split the memory straight down the middle, allocating one half to the CPU and other half to the graphics chip. But depending on needs, some distribution makers allow the central processor to have a larger share in order to improve performance in specific tasks.

Most distributions provide multiple copies of the start.elf file, one of which is chosen when the Pi boots. These preconfigured files sit in the /boot directory, and the files starting with the word arm contain the firmware files. They are identical, expect for one small change. And that is the amount of memory they reserve for the CPU — the higher the number in the filename, the more the amount of RAM that is reserved for the processor. To change this simply delete the start.elf from the /boot directory and copy the version that you would like in its place. The easiest way to do this is by typing the following at the terminal:

sudo cp /boot/arm224_start.elf /boot/start.elf

sudo reboot

Now when you reboot your Raspberry Pi, the central processor will have 224MB of RAM allocated to it, and the rest will be reserved for the graphics chip. To change the memory split, simply repeat the above command with a different start.elf file that you would like. Just make sure you rename the file to start.elf or the Pi won’t boot up.

Tuning the video output

Similarly video output can be configured in a myriad of ways using the config.txt file. Most of the default settings will work fine on most Pi systems, but video output is one area that usually requires some tinkering. The two main problems are overscan and underscan — and these often show up when using composite video output. If you can, then always use HDMI, as that will often save you from video troubles, but (since it also carries sound) from audio ones as well.

Turn your Pi into a Kiosk

Along with the myriad of possibilities that your Raspberry Pi provides, it also makes for an impressive Kiosk system. Kiosks are everywhere, in a doctor’s waiting room, in shopping malls, metro stations, business and corporate offices, you name it. Most old ones consist of an ancient and rusty TV set with a DVD player (or even a vintage VCR) attached, and they consistently play a promotional video on a loop.

Modern kiosks, on the other hand, bring the latest news, weather (and advertisements, obviously) on crisp, large screens. And this is what separates them — good kiosk systems usually do not repeat the same stuff till the end of time. Instead they update the displayed content via the Internet. And this is where the Pi really shines. It is a perfect solution that has everything you would want in a powerful, yet affordable kiosk system.

The most important software that you will need to build a modern kiosk system is a web browser. Modern web browsers are equally adept at displaying text as they are for showing multimedia content. All you need to do is to figure out a way to display the information that you would like to present as an HTML page, and you are already half way there. The other half is disabling the menu bars and UI of the browser, and then making sure that the browser refreshes the content automatically at a set interval. Almost all modern browsers already have a kiosk mode that does this automatically.

How you set up your kiosk display, and what you decide to show on it is entirely up to you. It could be a live Twitter feed of your official company account, some promotional slides that showcase your business, a website, publicity videos, audio messages — the possibilities are endless. Obviously your Pi is only half as fun when it is not connected to a network (or the Internet, for that matter), and this is exactly what you will learn to do in the next chapter.

Networking With Pi

Just like any other modern computer, the true power of the Raspberry Pi is unleashed the moment it is connected to the Internet. With just the plug of a cable (or insertion of a wireless dongle) the Pi can be used for all sorts of tasks, from surfing the web to posting tweets or streaming Internet media. But the Internet is just one facet of networking on the Raspberry Pi. The device can be accessed via Secure Shell, and the desktop on the Pi can be shared with other computers over a network (or vice versa). The more adventurous among you can even turn your Pi into an affordable yet powerful web server to serve both static and dynamic content. The networking possibilities on the Pi really are endless.

The Midori web browser

The browser that comes bundled with most Debian distributions by default is Midori. It is a serviceable option, though nowhere near as powerful as other competing offerings on the market. Although Midori is still in its infancy and it comes with a few limitations in terms of technologies that are on offer, its main standout feature is that it does not use a lot of memory — and RAM is a premium luxury on the Pi, for now, at least.

Speaking of technologies, both Flash and Java are not available on the Pi currently. Meaning if you come across a website that it built using either of these technologies, they will not work in any web browser running on the Pi, let alone Midori. Nevertheless, Midori plays nicely with HTML5, CSS3 and JavaScript and renders most modern websites properly, save for a select few that heavily depend on these three web technologies.

In case you find Midori slow when rendering some websites, a good option is to disable JavaScript altogether. This can improve usability on a lot of sites, as many websites will serve a plain HTML version of their service when they detect that JavaScript is disabled in the browser. The HTML versions of these websites will not have all the fancy features, but they will at least function. Another good solution is to use mobile versions of websites — this particularly holds true for the regular Twitter website which is slow on the Pi, but its mobile version provides a decent Twitter experience.

Install Chromium

While Midori is fine for confined and controlled web browsing, you may have to install a different browser in order to use some advanced websites. There are a number of solutions available on the Pi, but one of the most popular (and capable) ones around is Chromium. This is an open source project that Google’s Chrome browser is based upon. Open a terminal window and type the following:

sudo apt-get install chromium-browser

Before hitting the Enter key, double check that you have typed the name of the package correctly — chromium-browser is the web browser, while chromium is actually an arcade video game. Immensely fun, but it will not allow you to surf the Internet. While Chromium is an excellent choice, another good lightweight solution is Mozilla Firefox, also available for the Raspberry Pi.

Use Secure Shell

If you have connected your Pi to a network (home or office) you might want to access it from other computers and vice versa. The best way to communicate securely between two computers is Secure Shell (SSH), a universally popular network protocol designed for secure data communication. Raspbian already comes with support for SSH, and includes everything you need to start using it. All you have to do is configure a few things like password and authentication and you are on your way.

There are a number of popular SSH clients available for other operating systems (from Windows to Mac OS X, Android to iOS) that can be used to access your Raspberry Pi remotely. You can log into your Pi using SSH and access the Pi’s file system, start and stop any processes you want, and obviously monitor what is happening on the Pi at any given moment. The only major disadvantage of using SSH is that it works only in a text terminal. To use your Pi desktop you will have to opt for another solution.

Share your Pi desktop with your computer

Virtual Network Computing (VNC) is a new technology that overcomes the limitations of SSH by allowing you to control the Pi desktop, complete with keyboard and mouse, using another computer. It actually transmits the screen itself, along with all mouse and keyboard events from your Pi to any chosen computer. To enable VNC you will need a VNC client and server. As you would have guessed, the server runs on the machine that you want to control, and the client powers the controlling machine.

Say you want to control your Pi using your desktop or laptop PC. For this you will have to install a VNC server on your Pi. There are several solutions available, but perhaps the best one around is TightVNC. This free application is available for all major platforms, and on the Raspberry Pi you can easily install it via apt-get by typing:

sudo apt-get install tightvncserver

When you start the application for the first time after it is installed, it will ask you to set up a password to access your desktops. Follow the instructions on the screen and set up a secure password in the VNC client to prevent unauthorized access to your Raspberry Pi. TightVNC also allows you to define a view-only password if you want. This gives people read-only access so they can only see the screen, but cannot control the keyboard and mouse — quite useful for presentation purposes.

This is where the Virtual part of VNC kicks in. After setting up of the passwords, TightVNC creates a new virtual screen that can be accessed from any computer where its client is setup, be it a PC or a Mac. Apple computers actually come with a VNC client built-in, but for the Windows PC several free solutions are available. And the great thing about virtual screens is that you can create as many of them as you need. They do not necessarily correspond to the real physical screen of your Pi, meaning you can set up and access as many independent desktop environments as you would like.

Serving Pi

While the Raspberry Pi is significantly less powerful than most computers in a data center, and may look like a toy compared to modern server hardware, it still does the job as a useful server for home or office use. The small amount of memory and an underpowered processor are two obvious drawbacks, but the low power requirements and silent running still makes the Pi a great choice for serving simple pages to a local network, or even onto the Internet. It can serve static websites just as well as dynamically generated content from databases.

The first thing you need to turn your Raspberry Pi into a web server is a network service that understands the Hypertext Transfer Protocol (in other words, an HTTP server). Apache HTTP server and Nginx are two of the most popular solutions available for traditional computers, and these also work fine on the Raspberry PI. But Lighttpd is an even better choice for the Pi because of its very low memory footprint. Installing Lighttpd is a breeze:

sudo apt-get install lighttpd

Once the installation is complete, you can get Lighttpd up and running, and then point your web browser on the PC to the IP address of the Raspberry Pi. You will be greeted to the server’s welcome page as shown below.  The welcome page provides several helpful instructions on where to place the web pages you created. You can also install PHP on your Raspberry Pi to work with dynamic content and build your own applications that can be served from the Pi.

You can also install a LAMP stack on your Pi. LAMP stands for Linux, Apache, MySQL and PHP, a popular combination of software that is used to turn a computer into a fully functioning web server. Linux is the underlying operating system, Apache the web server, MySQL the database backend, and PHP, the scripting language for creating dynamic pages.

A LAMP based server can easily run all sorts of complex packages, like content management systems (Wordpress) to forums (phpBB) and everything in between. If you are using Raspbian, the Linux portion of LAMP is already taken care of. Type the following in a terminal window to install the three missing components:

sudo apt-get install apache2 php5 php5-mysql mysql-server

Ultimately, what you can do is dictated by the amount of memory you have. All kinds of web serving is possible with the Raspberry Pi as long as you keep your expectations in check and not anticipate performance similar to a powerful commercial server sitting in a data center. But the thing with web servers is that they work best when they have access to plenty of memory. If you are using your Pi solely for the purpose of serving web content, then it is best to switch the memory partition to a split in favor of the CPU and not running the graphical user interface (GUI) at the same time.

Multimedia Pi

One of the most popular uses of the Raspberry Pi is that of a home theater PC (also known as HTPC). In fact, the Broadcom chip that sits in the heart of the device was specifically developed with multimedia capabilities in mind. Add to this the power and flexibility of the Linux operating system and you can use your small and affordable PC to play and stream anything that your heart desires — from photos and music to high-definition videos.

Use XBMC to turn your Raspberry Pi into a multimedia center

It is one thing to being able to view images or play audio, even video on a Raspberry Pi, almost any modern multimedia device can do that. But the real fun is taking the entertainment to another level by turning your Pi into a complete multimedia center.

The small size, low power consumption and reasonable graphics capabilities make the Raspberry Pi a perfect option for a fully integrated multimedia center, not unlike a PlayStation 3, Xbox 360 or Apple TV. To do this, you will need some additional software that has to be installed — XBMC. Think of this as a media player on steroids that can turn any computer into an entertainment hub for digital media.

Bring Raspbmc into the picture

XBMC is more than a software application — it is a complete project, and a rather large one at that. Installing and configuring it takes quite some work even on a regular PC, but on the Pi it can sure be tricky. Fortunately, thanks to the stupendous efforts of the Raspbmc team, you do not have to do it yourself for the Pi. Raspbmc is actually a Linux distribution for the Raspberry Pi that does nothing else but run XBMC.

Just like any other distribution, you copy an image of it onto an SD card, and then use it to boot the Pi. And instead of a terminal or desktop environment, it starts up XBMC for you automatically. Ingenious! Even more ingenious is the fact that the Raspbmc team do not offer a complete image file that you have to download. Instead, you get an installer for all major platforms, which automatically handles this for you and copies all necessary files it to your SD card.

A word of caution, though — if you already have an SD card that you use with the Pi, be aware that installing Raspbmc on it will delete the content of the cards. Unless you exclusively want to use your Raspberry Pi as a multimedia center, then back up any files on your SD card that you want to keep. Or better yet, buy a second SD card specifically for Raspbmc use. This way you can easily switch between the two distributions.

Once the installation process is complete, Raspbmc is automatically started when you turn on the Pi. On first start up, it will probably open up a few dialog boxes notifying you of broken add-ons and plugins. Disable them for now, and feast your eyes on the main menu of XBMC in all its shiny glory. Most of the functions are self-explanatory, and you should have no problems if you have ever worked with media files on your computer before.

Controlling XBMC remotely

A media center is not much of a center if you have to go in and do everything manually — sooner, rather than later you will feel the need for a remote control. You can go out and buy some special hardware with an infrared dongle, but the easiest way to accomplish this is using your smartphone. XBMC is a modular platform and offers plenty of add-ons, along with web interfaces that provide the option of controlling XBMC remotely.

But first of all you will have to go to the System > Settings > Services > Webserver menu and enable the ‘Allow control of XBMC via HTTP’ option. With that done, you get the ability to use it with any browser that has access to your network. You will get a web interface, complete with the usual buttons like play, pause, stop, so on and so forth.

Since the idea is controlling XBMC remotely, how about using a good old-fashioned remote control? If you have a mobile device (tablets or Apple and Android smartphones) then you can install native remote control apps for XBMC — there are apps that look and work just like a normal physical remote. They not only look beautiful, but in many ways provide functionalities that go beyond regular remote controls for TV sets.

Streaming Internet media

Adding files to XBMC is easy as pie (pun always intended). You can add new movies, TV shows and music using the Add Files option in the Videos or Music menu. But the thing is that XBMC is not just a humble media player. It is by all accounts a full featured media library in that it tries to get as much information about your media files automatically as possible. This is where the Internet comes into the picture. XBMC can scan your media library and gather additional information from the web — for example the original airdate of a TV show episode, or the cast and crew of a film.

This integration with the web transitions over to add-ons as well. XBMC boasts a growing collection of add-ons and plugins, many of which give you access to media on the Internet. By default, however, XBMC is configured to play multimedia files that it can find on the Pi itself. But these add-ons are a game changer in that they easily provide Internet streaming capabilities to the device. And these include various TV channels, video sharing websites, and even specific add-ons for popular YouTube channels.

And you are not just limited to Internet video. You can also view images and photos from websites like Flickr, Picasa, The Big Picture or stream audio content from SoundCloud, Sky.fm, Grooveshark and other such websites on the Internet — all using a small, affordable device, all using impressive contributions from the XBMC (and Linux) community.

Pi Productivity

The extreme flexibility of the Raspberry Pi makes it a perfectly fine general purpose computer that can be used for home, office or school productivity. Sure, it will never match the performance of a standard desktop or laptop, but then again it never promised this in the first place. Nevertheless, Pi’s leisurely performance is reasonably offset by its low power and price requirements.

What’s on offer?

Although Raspbian, the official Raspberry Pi distribution, does not include any of the usual software solutions that are bundled with regular PCs, there is a growing list of productivity applications (word processor, spreadsheet, graphic design, image editing) that are being ported to the platform. These can be easily downloaded by a simple type of the apt-get command.

Then again, a local install is also not an absolute necessity. You can skip the download and install, and instead opt for cloud-based software through the web browser. Some flexibility and advanced functionality will have to be sacrificed, but the upside is increased performance.

We will take a look at some of the most popular solutions below. But before that, a tip for those of you that plan on using your Raspberry Pi as purely a productivity machine. It is absolutely recommended to reserve more than 256MB of memory for general purposes, and use a lesser amount for the graphics processor. This can be easily done by adjusting the available memory as discussed in the ‘Configuring The Pi’ chapter earlier in the book.

Suite it up with OpenOffice.org

One of the most popular productivity solutions around is OpenOffice.org. Initially designed as an open source, cross-platform alternative to the dominant Microsoft Office suite, it has grown remarkably powerful and robust over the years, and offers almost the same level of functionality as its universally popular competitor. It is formally developed for Windows, OS X and Linux, and then ported to other operating systems.

For Pi, however, this functionality comes at a bit of a charge. The OpenOffice package is no slouch — it needs at least 400 megabytes of storage space on the SD card once all dependencies are downloaded and installed. This means that not only will you need a 4GB or larger SD card, but expanding the file system becomes an absolute necessity. You will have to do this before you install the OpenOffice.org package, lest you find yourself running out of space before the productivity suite is set up.

But once the storage issues are sorted out, installing OpenOffice is as breezy as any other application available for the Pi platform. Yes, it comes with a bucketful of additional packages that are required to be downloaded, but everything is automatically taken care of with a single command. Just fire up a terminal window and input the following:

sudo apt-get install openoffice.org

Life doesn’t get any better than this, eh? If, however, you receive any error messages about missing files or something along these lines, just make sure your cache is up to date. Run the sudo apt-get update command to refresh the cache and try again.

The set up should take a little while depending upon your Internet speed, but once installed, OpenOffice.org will appear in the Applications Menu in the desktop, as series of entries. These include:

OpenOffice.org (main application with links to individual programs)

Base (database management system, similar to Microsoft Access)

Calc (spreadsheet application, like Microsoft Excel)

Draw (illustration application for drawing vector images)

Impress (presentation application, think Microsoft PowerPoint)

Math (create scientific formulae and equations)

Writer (word processor, equivalent to Microsoft Word)

For those of you that have worked with other productivity applications before, most of the programs in the OpenOffice.org productivity suite will be right up your alley. If anything, the interface is even more simplified and easier to pick up and play.

The only thing worth noting is that OpenOffice.org uses the ODF (Open Document Format) by default to save and load files. This open source standard is actually compatible with almost all productivity applications including new versions of Microsoft Office, so nothing to worry about here. Nevertheless, you also get the option of selecting a variety of alternate file formats.

One final thing of note is that OpenOffice.org is by no means the only productivity suite available for Raspberry Pi. Another perfectly valid alternate is LibreOffice — this is another free solution that actually descended from OpenOffice.org and offers almost the same level of advanced form and functionality that you would expect from an impressive and effective solution.

Image editing with The Gimp

Although OpenOffice.org comes with a vector drawing and illustrative work program (Draw), it does not offer the ability to edit images or touch up digital photographs. For image editing, the absolute best solution available on Linux is The Gimp (GNU Image Manipulation Program). It offers powerful features for digital image editing — a lot of which are comparable with the industry-standard commercial solution, Adobe Photoshop. Even the user interface is quite similar to Photoshop in more ways than one.

As is the case with OpenOffice.org, The Gimp is not installed by default in most Raspberry Pi distributions. So you will have to scout it personally by connecting your Pi to the Internet and downloading it through apt-get. And just like OpenOfficer.org, The Gimp takes a fair amount of storage space on the SD card — though admittedly nowhere near as the productivity suite. But just make sure you have enough space available before proceeding with the installation. Open up a terminal window and type the following:

sudo apt-get install gimp

The user interface of The Gimp may be a bit stunning for those of you that use it the first time, with three different windows rather than one. But the icons are bright and colorful, and you can be up and running after playing around with the application for a few minutes. If you find the learning curve steep, a pretty helpful User Manual can also be downloaded — it has rather large space requirements and is not installed by default. However, you can easily read a web-based version of the User Manual instead.

The Gimp is a very powerful tool, and as expected, it uses a lot of memory. And consequently it runs relatively slow on the Raspberry Pi. Still, it is definitely usable as long as you are patient, particularly when opening large photos and image files. If you regularly work in The Gimp, it is a good idea to increase the amount of system memory. Again, refer to the ‘Configuring The Pi’ chapter earlier.

Cloud services to the rescue

Cloud computing is undoubtedly the next frontier of computing. More and more companies have started offering cloud-based versions of their software. And if your Raspberry Pi is connected to the Internet most of the time, then cloud-based applications make perfect sense. Not only do most offer a powerful feature set, they are also lightweight and easy on system requirements — as most of the processing is done in the cloud, on the servers.

For those that are not aware of what cloud-based software solutions are, or how they work, here is a brief description. They are called cloud-based software for the reason that these applications do not live (as in not installed) on your computer like traditional programs. Instead the source code is stored on powerful servers in large datacenters around the world — hence the fancy term, cloud.

These servers have immense computational prowess and work very fast to push whatever work that you do (like word processing or even graphic design) to Internet browsers. For Pi, this means that very little processing is required, and hence you can work on advanced documents or tasks without slowing down your system. Plus, another advantage is that all applications based on the cloud look and work the same way on all platforms. Files are also stored in the servers, and can be accessed from anywhere, anytime.

Still, these cloud servers are not without their drawbacks. In other words, they are not perfect. Most lag behind their desktop counterparts and traditional software when it comes to features and functionality. They may support fewer formats, for example. And it goes without saying that cloud-based applications do not work when there is unreliable or no Internet connectivity.

Nevertheless, most of these imperfections are being improved upon regularly. All popular cloud-based applications get new features on a constant basis to bring them in line to their desktop counterparts. Large software companies like Microsoft and Google are investing heavily in this dynamic new field, and already offer several robust cloud-powered solutions — most of which are a perfect fit for the Raspberry Pi. Here is a list of some of the most popular ones, along with brief descriptions of each:

Google Drive

A cloud-powered service run by the search engine giant, formally known as Google Docs. It offers a word processor, along with spreadsheet and presentation applications.

http://docs.google.com

Office 365

Microsoft’s entry in the cloud arena is a great choice for Microsoft Office users. It offers the same user interface as its desktop counterpart and is remarkably powerful. However, it requires a monthly subscription fee, and unfortunately has no free user level.

http://office365.microsoft.com

Zoho

One of the most popular choices, Zoho has more than five million users. More than just a simple productivity suite of applications, it offers several business centric features like a knowledge base system, web conferencing, and customer relationship management. Again, some require a paid account.

http://www.zoho.com

ThinkFree Online

This is another popular web-based software solution, offering word processing, spreadsheet and presentation software for free — with 1GB of storage space for users.

http://online.thinkfree.com

A word of caution for these cloud-based services, though. Most of these are advanced solutions and require an advanced web browser, surely something more advanced than the default Midori. The Chromium browser discussed in the ‘Networking With Pi’ chapter is a highly recommended solution for these cloud-powered applications. Mozilla Firefox is also a powerful alternate for the Pi, which actually comes as the default browser on the Fedora Remix distribution.

By now you have a crystal clear idea of just how much work this amazingly affordable computer can do. Raspberry Pi can serve as a server, and oblige as a productive worker. But just like in real life, some well-earned play time comes after a hard work shift, so let’s get to some gaming on the Pi next.

Time For Some Pi Gaming

Let’s get this little fact out of the way straight up — Linux has never been a popular gaming platform. Things are improving however, with one of the most popular PC gaming services (Steam) now offering dedicated support for Linux titles. But it still takes years until blockbuster titles are coded for the Linux platform. That is not to say there are no entertaining video games available for the Raspberry Pi. There are several engaging titles for the platform, and a whole world of fun awaits you.

Emulating other platforms

Low as it is in the performance column, the Raspberry Pi still has enough capabilities to emulate some home computers and gaming consoles from the years gone by. Case in point, you can easily play all games made for the immensely popular Atari VCS 2600 on the Pi — classic and vintage, yes, but fun and entertaining, nevertheless.

To enjoy some fine emulated games on your Raspberry Pi, you will need an emulator. This is a software application that rebuilds and imitates the hardware of a certain console or home computer. When you run an emulator on the Pi, you get the ability to work with the emulated system as if you have the original hardware in front of you. You can pretty much run all software and games that were available for these systems in the past.

While emulating sounds all fun and games, the thing worth noting here is that it is an extremely difficult and resource intensive process — sometimes even for simple systems. Without delving into too much detail, just understand that while the Pi will have trouble keeping up when emulating a lot of newer systems, some popular old ones are a walk in the park for it.

One system that the Pi can emulate perfectly fine is the aforementioned Atari 2600. And there are countless games available for this classic console, with the Pi community even creating new titles this very day and age. So popular is the console that there are several emulators that exist for it. The most popular of the bunch if Stella, which you can install as follows:

sudo apt-get install stella

When you first start Stella, it asks you for the directory where it should look for ROMs. While almost all Atari ROMs are available on the web, most are still copyrighted. But you buy collections of Atari games that publishers have packed together in a CD for very little money. And these can then be played on Stella to bring back the warm and fuzzy childhood feelings. Of course, as mentioned above, new games are always created for this platform by the open source community.

Native games

Playing games that were released on other systems using virtual machines and emulators is an absolute blast, but the fun does not stop here. The Raspberry Pi has enough computational power to run a lot of native Linux games too. The LXDE desktop has a compilation of a number of classic games that have been coded in Python — games like Four in a Row, Snake and other such timeless titles.

But at the end of the day a Pi is a regular Linux system, and this means it is possible to play any and every game that is compatible with your current distribution, as long as the Pi has enough resources available to run it. The idea here is to scout the web for titles that have been coded and tested to work on the Raspberry Pi. Ports of classic games like Tetris or Pac-Man are abundant — and you can find some really good clones that can be installed and played.

In fact, clones of classic games aside, the Pi actually has enough power to run (relatively) modern masterpieces like Quake II and Quake III — two of the most famous first person shooters of all time, the latter of which was released back in 1999. There may be a few problems here and there, but for the most part both games are legitimately playable. And so is Minecraft: Pi Edition that was released recently for the platform in early 2013.

Genres on offer

There is a wide array of video game genres available for the Raspberry Pi, from shooters to racing. But when it comes to native games the most popular of the lot, by far, are adventure games — text-based adventures and point-and-click adventures. Think games like The Secret of Monkey Island and other such colorful adventures, which have been ported over by the open source community.

Interactive fiction is another highly popular genre. It finds its roots in the era of the earliest home computers, and focus on telling great stories instead of the flashy presentation and spectacular 3D graphics. Most of these games tell long and elaborate stories, and hence the term interactive fiction. But so engaging are these games that a lot of them will entertain you for many hours.

The Pi may not be a formidable console or beefed up gaming PC, but it can still provide plentiful entertainment with games that you may not find on most modern platforms. And considering just how much functionality the Raspberry Pi provides for other tasks, the ability to play classic games to kill some time is just an added bonus. The next chapter deals with a completely different and highly technical topic. You will learn some basics about genius stuff like programming and electronic projects.

Next Steps

It is remarkable to think that the Pi community has come so far in such a little time, with ports of software and games, multimedia and network capabilities. But at the same time it is easy to forget that the Raspberry Pi Foundation originally built the Pi for teaching kids how to program and tinker with electronics. So far you have learned about how to use programs that other people have written for the Pi. Now is the time to write your own. A detailed discussion on this extensive topic is out of the scope of this book, but here some pointers for those interested.

Programming with Scratch

As mentioned above the Raspberry Pi was actually designed as an education tool to encourage kids to program and experiment on the computer. For this reason it comes preloaded with a bunch of interpreters and compilers for many of the most popular programming languages. But for the absolute beginners, there is Scratch — a graphic programming language that comes from the MIT.

The Lifelong Kindergarten group of the MIT Media Lab developed Scratch as a simple new way to teach programming to very young people. As the image above shows, Scratch is different from traditional languages that are heavy on code in that it constructs programs from colorful blocks — each of which perform a specific operation. These go a long way in eliminating the syntax problems that confound many users that are using a text-based programming language for the first time.

In a nutshell, Scratch is a friendly (yet powerful) environment for creating things quickly. It is an accelerated platform to learn the basics of coding, if you will. A young programmer can create blocks of code, and see them highlighted as they are executed. He or she can change the blocks and then see how it affects their creation in real time.

The Scratch environment contains everything in one vibrant window, with subpanels for block palettes, a scripting and costume area, along with a list of sprites and a stage. Sprites are an important part of Scratch, and they can be manipulated on the stage. Better yet, there is a very vibrant community of Scratch users that share sprites and bits of code with others in the community.

Python on the Pi

If you want to take your computer programming to the next level and start writing deep code, then the Python programming language is a great way to start. Although any text editor can be used for scripting, the IDLE integrated development environment provides enhanced features that make coding easier and more comfortable. The reason you see two versions (IDLE and IDLE3) of IDLE is that there are two version of Python installed on your Pi.

Python has two versions that are actively used — version 2 and version 3. Most people write scripts in Python 2.x, and many projects are developed using this. In fact, version 2.x has several other things going for it, like the biggest collection of libraries, a large amount of documentation and community content like blog and forum posts.

Python 3.x, on the other hand, comes with a lot of language improvements and tweaks that will never be available for 2.x, as all new ideas and development is focused on the latest version. Ultimately though, if you are starting out your programming career, it is best to focus on Python 3.x, as that is where the future is. While there are differences between both versions, in reality, going from one to another is not as big a problem as it may seem.

Python is a very powerful programming language, and is used for all sorts of things. For those of you interested in getting started in learning Python, www.python.org is a great place to get started. But Scratch and Python are not the only two languages available on the Pi — you can write programs for your Raspberry Pi in a number of different programming languages like C, Java, Ruby and Perl.

Build and control small electronic devices using GPIO ports

The Raspberry Pi differentiates itself from a regular computer not just in its price and size, but also its ability to integrate with electronics projects. That is the reason why the Pi comes with an expansion header for connecting your own electronics projects. You can use the Raspberry Pi to control everything from LEDs and AC devices after procuring inexpensive equipment from almost any electronics store.

GPIO is short for General Purpose Input/Output ports, and they provide an easy way to connect hardware to your Pi that you can then control using software. For example if you want to build a light sensor, you can make a device that connects to your Pi — and do it via the GPIO ports. Of the two most popular programming languages on the Raspberry Pi, Python can make the use of its GPIO ports to communicate with external hardware, which is unsurprising when you consider that it is a more powerful (and significantly more complex) programming language than Scratch.

Obviously those of you that do not have an interest in any hardware projects can forget about the GPIO ports. But they are a very alluring bonus for people that want to integrate their Pi with their school or college project, or some hardware that they are building, or maybe even making their Raspberry Pi the brain of their invention.

Troubleshooting And Overclocking

As much as we all would like things to go smoothly, there are times when they do not. The thing with technology is that the more complex the device, the higher the chances of problems to occur. And as simple as it may seem on the front, the Raspberry Pi is, at its very core, quite a complex device. Luckily, the most common problems are easy to pinpoint, straightforward to diagnose and simple to fix.

Fix common problems

Your Raspberry Pi may misbehave every now and then, but the most general problems that users experience are related to device connectivity (keyboards and mouse, for instance), power or display. Occasionally, you may encounter slightly more severe issues like boot or network problem, or in rare cases of adventurism, hardware or kernel concerns. Here is a brief overview of these:

Device connectivity

This is perhaps the most common everyday problem that Pi users encounter. Their keyboards may repeat certain characters, or the mouse stops responding. The two main reasons for this are either the devices are drawing too much power, or they are conflicting with the USB circuit of the Pi.

Also confirm whether the keyboard or mouse that is being used is compatible with the Linux distribution you have installed, or if possibly try other keyboards and mice to be doubly sure.

Power supply

Another issue that can be the case of many problems is of an inadequate power supply. Model A of the Pi requires a 5V supply that can provide a 500mA current, while Model B ups this to 700mA. But sadly not all USB power adapters supply this much power, even if their labels say they do.

Display

The thing about Raspberry Pi is that it has been designed from the grounds up to work with almost all HDMI, DVI or composite video devices. But there may be instances when it may simply not work as expected once you plug it in — the picture may be missing entirely, or visible only on a part of the screen, or there may be an issue with colors.

This usually boils down to the display cable in question, or the monitor (or TV) may be up to no good.  Sometimes the issue stems from the settings in the display, like overscan or even country specific settings, as different countries use different standards for TV video.

Boot problems

Ever get that sinking feeling when your computer fails to boot up? The most common reason why the Raspberry Pi fails to boot up or start is the SD card. This is because unlike traditional PCs like desktops and laptops, Pi relies on the SD card for everything — all the files are stored on it, it is the be all and end all as far as the system files are concerned.

If you connect the microUSB power supply and the power light on the Pi glows, but the OK light remains dark, then this is almost always a SD card problem. Make sure the card works on another PC, shows the partitions correctly along with all the files you would expect to be on it.

Network issues

Honestly speaking, network issues can often be a pain to sort out. The Raspberry Pi actually includes a very useful tool for diagnosing network problems called iconfig. Just type the name in a terminal window and the tool will provides relevant information on connected network ports.

The first solution to a network problem is to try and disable, then enable the network interface. You can do this by typing sudo ifdown eth0 in a terminal window, then make sure the cable is correctly connected at both ends, and finally enable the network by typing sudo ifup eth0. Finally test the network by typing ping in the terminal, just as you would do so on a normal computer.

Overclocking the Raspberry Pi

Now this is something that not many will indulge in, but the Raspberry Pi can easily be overclocked (from its base speeds) for a little extra performance boost. Overclocking the Pi is not overly different from overclocking traditional computers. The config.txt file not only controls the graphics output of the BCM2835 processor but enables controlling the chip in other ways as well.

Specifically, it allows the ability to alter the speed at which the chip runs — increasing its performance at the expense of the lifespan of that particular part. As mentioned earlier, the Broadcom BCM2835 processor that beats as the heart of the Raspberry Pi is a system-on-chip (SoC) design that is split into two main parts — the central processor (CPU) and the graphics processor (GPU).

With overclocking you can now run the processors at speeds higher than the default 700 MHz clock speed. There are detailed instructions on the Internet on how (and how much) to overclock the hardware. As mentioned above this procedure does not come without risks. You do get performance gains, but you could potentially break your Pi — in other words brick it. The chip lifespan is, after all, the main reason why Pi is not provided with higher clock speeds right out of box.

Besides, SoC platforms rarely have much headroom for overclocking, unlike desktop processors and video cards. But those of you that want faster gameplay, smoother video playback or overall increased performance in tasks and programs on their Pi, can definitely increase the CPU and memory clock frequencies, or even do some advanced overvoltage adjustments to eke as much performance as possible.

Resources

The Raspberry Pi may be one of the newest kids on the block, but it is fast becoming a favorite. The most inspiring thing about the Pi is not the hardware or software, but its fans in the technology community that have put together all sorts of tutorials and projects that make use of the Pi. Below is a brief, but helpful list of some of the best online resources and links to Raspberry Pi websites.

List of online resources

The official Raspberry Pi website is perhaps the one that you will visit most frequently for news as well as downloads. The Pi fever has actually spread to all corners of the Internet, with forums, blogs, social communities, as well as authority websites all covering everything Raspberry Pi in great detail. Here is a small selection of some the best:

Raspberry Pi Foundation

Official website containing everything from elaborate documentation to engaging downloads for the famous ARM based computer. This one goes into your bookmarks straight away.

http://www.raspberrypi.org/

Raspberry Pi Wiki

A detailed wiki managed by the Raspberry Pi community, containing resources like documentation, datasheets, troubleshooting as well as projects and guides.

http://www.elinux.org/RPi_Hub

Raspberry Pi Forums

You are bound to find tons of great information on the official message board for Raspberry Pi.

http://www.raspberrypi.org/phpBB3/

Raspberry Pi Google+ Community

With more than 40,000 members, this is the definitive Pi community on Google’s social network, and boasts tons and tons of great content. Must join if you are on Google+ and have any interest in the PI.

http://plus.google.com/communities/113390432655174294208

Raspberry Pi @ Reddit

The Raspberry Pi page on Reddit is always filled with lots of good information.

http://www.reddit.com/r/raspberry_pi/

Raspberry Pi Kid

This remarkable blog was started by an 11 year old kid with the goal of experimenting and documenting her Raspberry Pi adventures. This one is definitely worth a visit.

http://raspberrypikid.wordpress.com/

Raspberry Pi Blog

This hardware centric Raspberry Pi resource contains lots of tips, tricks and information.

http://www.rpiblog.com/

RaspbiHub

This website collects and aggregates all the latest news from a number of different sources, making for a good daily read if you are a Raspberry Pi enthusiast.

http://www.raspihub.com/

Raspi.TV

This active blog covers a lot of Raspberry Pi hardware in detail, with several advanced tutorials to help you with projects.

http://www.raspi.tv/

Raspbmc

Point your browser here if you want to turn your Raspberry Pi into a fully featured media center.

http://www.raspbmc.com/

Legal Stuff

© 2013 Kevin Johnson

All Rights Reserved

All work contained in this book is copyrighted. No part of this document may be reproduced or transmitted for resale or used by any party without express written permission from the author.

Trademarks Notice

All products mentioned in this ebook and their trademarks are the property of their respective owners. The author is not associated with any product or vendor mentioned in this book.

Legal Notice

While all attempts have been made to provide effective, verifiable information in this document, the author does not assume any responsibility for errors, inaccuracies, or omissions. Any slights of people or organizations are unintentional. The information contained in this package does not make any claims or guarantees. The author has no control over what you may or may not do with this information, and therefore cannot accept the responsibility for your results. Any and all references to persons or businesses, whether living or dead, existing or defunct, are purely coincidental.

Uploaded by .X0RN. {Zer07} [BЯ]