Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Raspberry Pi for Secret Agents - Second Edition
Raspberry Pi for Secret Agents - Second Edition

Raspberry Pi for Secret Agents - Second Edition: Turn your Raspberry Pi into your very own secret agent toolbox with this set of exciting projects , Second Edition

eBook
€10.99 €16.99
Paperback
€20.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi for Secret Agents - Second Edition

Chapter 1. Getting Up to No Good

Welcome, fellow pranksters and mischief-makers, to the beginning of your journey towards a stealthier lifestyle. Naturally, you're all anxious to get started with the cool stuff, so we'll only devote this first, short chapter to the basic steps you'll need to get your Raspberry Pi up and running.

First we'll get to know the hardware a little better, and then we'll go through the installation and configuration of the Raspbian operating system.

At the end of this chapter, you should be able to connect to your Raspberry Pi through your local network and be up to date with the latest and greatest software for your Pi.

A brief history lesson on the Pi

The Raspberry Pi is a credit-card-sized computer created by the non-profit Raspberry Pi Foundation in the UK. It all started when a chap named Eben Upton (now an employee at Broadcom) got together with his colleagues at the University of Cambridge's computer laboratory, to discuss how they could bring back the kind of simple programming and experimentation that was widespread among kids in the 1980s on home computers such as the BBC Micro, ZX Spectrum, and Commodore 64.

After several years of tinkering, the Foundation came up with two designs for the Raspberry Pi. The $35 Model B was released first, around February 2012, originally with 256 MB of RAM. A second revision, with 512 MB of RAM, was announced in October 2012 and the $25 Model A went on sale the following year, in February 2013.

In July 2014, with over 3 million Pis sold worldwide, the Foundation unveiled the Raspberry Pi Model B+, a $35 final board revision incorporating numerous improvements requested by the ever-growing Pi community.

The following table shows the difference between the Raspberry Pi models:

What's onboard?

Model A

Model B

Model B+

Memory (RAM)

256 MB

512 MB

512 MB

USB ports

1

2

4

Storage card type

Standard SD

Standard SD

Micro SD

Power consumption

300 mA (1.5 W)

700 mA (3.5 W)

600 mA (3.0 W)

Ethernet networking

no

yes

Yes

The ins and outs of the Raspberry Pi

At the heart of the Pi is the Broadcom BCM2835 System on a Chip (SOC)—imagine all the common hardware components of a PC baked into a small chip. The CPU is called ARM1176JZF-S, runs at 700 MHz, and belongs to the ARM11 family of the ARMv6 architecture. For graphics, the Pi sports a Broadcom VideoCore IV GPU, which is quite powerful for such a tiny device and capable of full HD video playback. The following figure shows the Raspberry Pi Model B:

The ins and outs of the Raspberry Pi

Raspberry Pi Model B board showing key components

GPIO headers

At the edge of the board, we find the General Purpose Input/Output (GPIO) pins, which, as the name implies, can be used for any kind of general tinkering and to interface with other pieces of hardware.

The RCA video jack

The RCA video jack is for composite video output, which we can use to connect the Pi to one of those old television sets using an RCA connector cable. On the Model B+, this connector has been combined with the audio jack.

The Audio jack

We can get sound out of the Pi, either through the HDMI cable connected to a monitor, or from this 3.5 mm analog audio jack using headphones or desktop speakers.

Status LEDs

Status LEDs are used to tell us what the Pi is up to at the moment. They have the following meanings:

  • The green light labelled ACT will blink whenever the Pi is accessing data from the SD card
  • The red light labelled PWR should stay solid as long as the Pi has power
  • On Model B, the three remaining LEDs will light up when a network cable is connected to the Ethernet port

USB

The USB 2.0 ports allow us to connect keyboards, mice, and most importantly for us, Wi-Fi dongles, microphones, video cameras, and GPS receivers. We can also expand the number of USB ports available with the help of a self-powered USB hub.

The Ethernet network

The Ethernet port allows us to connect the Pi to a network at a maximum speed of 100 Mbit/s. This will most commonly be a home router or a switch, but it can also be connected directly to a PC or a laptop. A Category 5 twisted-pair cable is used for wired network connections.

The CSI Camera connector

The Camera Serial Interface (CSI) is where the official Raspberry Pi camera module connects to using a flexible flat cable.

HDMI

The High-Definition Multimedia Interface (HDMI) connector is used to connect the Pi to a modern TV or monitor. The cable can carry high-resolution videos up to 1920 x 1200 pixels and digital sound. It also supports a feature called Consumer Electronics Control (CEC), which allows us to use the Pi as a remote control for many common television sets.

Power

The power input on the Raspberry Pi is a 5V (DC) Micro-USB Type B jack. A power supply with a standard USB to micro-USB cable, such as a common cell phone charger, is then connected to feed the Pi.

Note

The most frequently reported issues from Raspberry Pi users are without a doubt those caused by insufficient power supplies and power-hungry USB devices. Should you experience random reboots, or that your Ethernet port or attached USB device suddenly stops working, it's likely that your Pi is not getting enough stable power.

Power

5.25V 1A power supply with USB to Micro-USB cable

Take a look at the OUTPUT printed on your power adapter. The voltage should be between 5V to 5.25V and the amperage provided should be at least 700mA. The official 2A power supply sold by the Foundation is highly recommended (1A = 1000mA).

You can help your Pi by moving your devices to a self-powered USB hub (a hub that has its own power supply).

Also note that the Pi is very sensitive to devices being inserted or removed while it's running, and powering your Pi from another computer's USB port usually doesn't work well.

SD card

The SD card is where all our data lives, and the Pi will not start without one inserted into the slot. The Raspberry Pi Model A and B takes a standard-sized SD card while the Model B+ uses the tiny Micro SD.

SD cards come with a wide variety of data storage capabilities. A card with a minimum of 4 GB of storage space is recommended for the projects in this book. The SD cards also carry a class number that indicates the read/write speed of the card—the higher the better.

Installing the Raspbian OS on the SD card

Computers can't do anything useful without an operating system, and the Pi is no exception. To help us add one, we'll be using the easy operating system installation manager called New Out Of the Box Software (NOOBS). NOOBS will let us choose from a growing list of operating systems available for the Pi, but we'll stick with the officially recommended OS—the Raspbian GNU/Linux distribution.

Getting NOOBS

There are two main ways to obtain NOOBS. You can either buy it preinstalled on an SD card from your Raspberry Pi dealer, or download NOOBS yourself and copy it to an empty SD card on a computer with an SD card slot.

Tip

If you do have access to a computer but it lacks an SD card slot, it's a wise choice to invest in an external SD card reader/writer. They don't cost much and chances are you'll want to re-install or try a different operating system on your SD card sooner or later.

To download NOOBS, visit the site http://www.raspberrypi.org/downloads, where you have the option of downloading the full installer that includes the Raspbian operating system image at about 740 MB in size, or the lite package that lets you pick and choose other operating systems to install over a wired Ethernet connection. Just click on the link for the full ZIP file and wait for your download to start or use the torrent link if you prefer, but we will not cover that in this book.

Formatting the SD card

Before we copy NOOBS to the SD card, it should be empty and formatted with the FAT file system. You can either use the native application of your computer's operating system to do so, or preferably the SD Formatter utility offered by the SD Association at http://www.sdcard.org/downloads. Perform the following steps in order to format the SD card:

  1. Download and install the utility for either Windows or Mac.
  2. Insert your SD card and start the application.
  3. Ensure that SD Formatter has detected the correct volume of your SD card.
  4. Click on the Option button and set format size adjustment to ON.
  5. Click on Format to erase and format your SD card:
    Formatting the SD card

    SD Formatter running in Windows

Starting NOOBS

All right, you've been patient long enough; it's time we take your Pi out for a spin! With your SD card formatted and the NOOBS download completed, extract the NOOBS ZIP file and copy all the contents to the SD card.

Note

To avoid data loss, remember to always safely eject your SD card from your computer by right-clicking the SD card icon and selecting Eject.

For this first voyage, it is recommended that you go easy on the peripherals until we have properly configured the Pi and verified a basic stable operation. Connect a USB keyboard and mouse, a monitor or TV, and a Wi-Fi dongle or an Ethernet cable plugged into your home router. Finally, insert your SD card and attach the power cable.

Within seconds, you should see NOOBS starting up with a reminder saying that if you ever want to return to NOOBS in the future, for recovery purposes or to try out another operating system, simply hold down the Shift key when you see the message.

Note

If your display remains blank after several minutes, try pressing the number keys 1 through 4 to switch between the different video output modes.

Finally, check the box next to Raspbian and click on the Install icon.

Starting NOOBS

Selecting Raspbian for installation in NOOBS

Installation will take around 20 minutes depending on the speed of your SD card.

Booting up and configuring Raspbian

Once NOOBS has completed the Raspbian installation and your Pi has been rebooted, you should see text scroll by on your display. These are status messages from the booting Linux kernel.

Booting up and configuring Raspbian

raspi-config application running on first boot

The output will come to a halt in a minute and you'll be presented with a menu-type application called raspi-config. Use your arrow keys to navigate and press the Enter key to select menu options. The menu options are as follows:

  • Expand Filesystem: This option is only useful for when you write a Raspbian image to your SD card directly, without using NOOBS. For us, this step has already been taken care of.
  • Change User Password: Select this option to change the password for the default user pi. This is strongly recommended. Just in case you forget, the default password is raspberry.
  • Enable Boot to Desktop/Scratch: This option allows you to change whether the graphical desktop or the Scratch programming environment should be started automatically each time you boot the Pi. Since we will mostly work on the command line in this book, it's recommended that you leave this option as is.
  • Internationalisation Options: This menu allows you to add non-English languages and keyboard layouts to the system. More importantly, it lets you set the correct time zone, because any scheduling we do in the later chapters depends on this. It's also nice to have the correct time in the log files.
  • Enable Camera: Select this option if you have a camera module connected to the CSI connector on the Raspberry Pi board.
  • Add to Rastrack: This is a completely optional way of adding your Pi to an online map (http://rastrack.co.uk) that tracks where people are using Raspberry Pis around the word.
  • Overclock: This option allows you to add some turbo boost to the Pi. Only experiment with overclocking once you have established that your system runs stable at default speed. Also note that while overclocking will not void the warranty of the Pi, it could reduce its lifetime.

The Advanced Options menu contains the following options:

  • Overscan: If you see thick black borders around the blue background on your monitor, select this option and disable to make them go away the next time you boot the Pi.
  • Hostname: This option allows you to change the name of your Pi as it appears to other computers on your local network. It is up to your home router to translate this name into the correct IP address of the Pi as we will see later in this chapter. The default hostname is raspberrypi.
  • Memory Split: This option lets you change how much of your Pi's memory the Graphics Processing Unit (GPU) is allowed to use. To use the camera module or play HD movies, the GPU needs 128 MB of the RAM.
  • SSH: Select this option to enable or disable the Secure Shell service. SSH is a very important part of our setup and allows us to log in remotely to the Pi from another computer. It is active and enabled by default, so leave this option alone for now.
  • SPI: This option enables support for a certain group of add-on boards that connects to the GPIO header of the Pi.
  • I2C: This option enables support for a group of add-on chips that communicate via I2C such as real-time clock modules.
  • Serial: This option allows or disallows communicating with the Pi via a serial cable and terminal application running on another computer.
  • Audio: This option can be used to force the audio output through either HDMI or the analog audio jack.
  • Update: This option will try to upgrade the raspi-config application itself to the latest version. You can leave this option alone for now as we will make sure all the software is up to date later in this chapter.

Once you're happy with the configuration, select Finish and Yes to reboot the Pi.

At the raspberrypi login prompt, enter pi as the username and enter the password you chose.

Basic commands to explore your Pi

Now that you're logged in, let's have a look at a handful out of the several hundred possible commands that you can type in the command line. When a command is run prepended with sudo, it'll start with super user or root privileges. That's the equivalent of the Administrator user in the Windows world.

Command

Description

sudo raspi-config

This starts raspi-config, which lets you reconfigure your system.

sudo reboot

This reboots the Pi.

sudo poweroff

This prepares the Pi to be powered off. Always type this before pulling the plug!

sudo su

This becomes the root user. Just be careful not to delete anything by mistake!

df / -h

This displays the amount of disk space available on your SD card.

free -h

This displays memory usage information.

date

This displays the current time.

top

This starts a task manager that shows running processes with the most CPU hungry applications on top. Press Q to quit.

exit

This logs you out of your current shell or SSH session.

sudo touch /forcefsck

This will enable your Pi to check/repair the root file system at the next boot. It's a useful command if you suspect your SD card data might be damaged.

Getting help with commands

Here are a few tricks that will help you get the hang of the Linux command line:

  • Command tab completion: If you can't quite remember the exact name of a command, but you think it stars with raspi, begin typing the first few letters and press the Tab key twice to get a list of all commands starting with those letters. Tab completion can also save you some typing when inputting directory paths and filenames.
  • Manual pages: Most commands come with a manual that describes the usage of the command in more detail. For example, to read the manual for the top application, type man top. Use the arrow keys to scroll and press Q to quit.
  • Built-in help: Most commands can be asked to print out a help text about their usage. The two most common arguments are --help and -h. For example, to see the help text for the ls command, type ls --help.

Accessing the Pi over the network using SSH

Pretty much all the pranks and projects in this book will be done at the command line while being remotely logged in to the Pi over the network through SSH. Before we can do that, we need to be sure our Pi is reachable and we need to know its IP address. First we'll look at wired networks, then at Wi-Fi.

Wired network setup

So you've plugged an Ethernet patch cable into the Pi and connected it to your home router, now what? Well, there should be all kinds of blinking lights both around the port of your router and on your Pi. The next thing that needs to happen is for the router to assign an IP address to the Pi using Dynamic Host Configuration Protocol (DHCP). DHCP is a common service on network equipment that hands out unique IP addresses to all computers that want to join the network.

Let's have a look at the address assigned to the Ethernet port (eth0) on the Pi itself using the following command:

pi@raspberrypi ~ $ ip addr show eth0

If your DHCP service is working correctly, you should see a line similar to the following output:

inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0

The digits between inet and the / character is your Pi's IP address, 192.168.1.20 in this case.

If your output doesn't have a line beginning with inet, it's most likely that your router lacks a DHCP service, or that the service needs to be enabled or configured. Exactly how to do this is outside the scope of this book, but try the manual for your router and search for dhcp.

For static address network setups without DHCP, see the Setting up point-to-point networking section in Chapter 5, Taking Your Pi Off-road.

Wi-Fi network setup

The easiest way to set up Wi-Fi networking is to use the included WiFi Config GUI application. Therefore, we will briefly enter the graphical desktop environment, configure the Wi-Fi, and save the information so that the Wi-Fi dongle will associate with your access point automatically on boot.

If you have a USB hub handy, you'll want to connect your keyboard, mouse, and Wi-Fi dongle now. While it's fully possible to perform the following actions using only the keyboard, a mouse will be very convenient:

  1. Type startx to start the graphical desktop environment.
  2. Click on the Menu button and then select WiFi Configuration located under Preferences.
  3. From the Network drop-down menu, select Add.
  4. Fill out the information for your access point and click on the Add button.

    If you're unsure about the Authentication type of your access point, pressing Scan might help you figure it out.

    Wi-Fi network setup

    Adding an access point in Wi-Fi Config

  5. Your Wi-Fi adapter will associate immediately with the access point and should receive an IP address, as listed under the Current Status tab.
  6. From the File drop-down menu, select Save Configuration.
  7. Exit the application and log out of the desktop environment.

To find out about the leased IP address of your Wi-Fi adapter (wlan0), without having to enter the graphical desktop, use the following command:

pi@raspberrypi ~ $ ip addr show wlan0

You should see a line similar to the following output:

inet 192.168.1.15/24 brd 192.168.1.255 scope global wlan0

The digits between inet and the / character is your Pi's IP address, 192.168.1.15 in this case.

To obtain information about the associated access point and signal quality, use the iwconfig command.

Connecting to the Pi from Windows

We will be using an application called PuTTY to connect to the SSH service on the Pi. The steps to be followed are:

  1. To download the application, visit this address http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
  2. Download the all-inclusive windows installer called putty-0.63-installer.exe, since the file copy utilities will come in handy in later chapters.
  3. Install the application by running the installer.
  4. Start PuTTY from the shortcut in your Start menu.
  5. In the Host name (or IP address) field, input the IP address of your Pi, which we found out previously. If your network provides a convenient local DNS service, you might be able to type raspberrypi. (with the trailing dot) instead of the IP address; try it and see whether it works.
  6. Click on Open to initiate the connection to the Pi.
  7. The first time you connect to the Pi or any foreign system over SSH, you'll be prompted with a warning and a chance to verify the remote system's RSA key fingerprint before continuing. This is a security feature designed to ensure the authenticity of the remote system. Since we know that our Pi is indeed our Pi, select Yes to trust this key and continue the connection.
  8. Log in as pi and enter the password you chose earlier with raspi-config.
  9. You're now logged in as the user pi. When you've had enough pranking for the day, type exit to quit your SSH session.

Connecting to the Pi from Mac OS X or Linux

Both Mac OS X and Linux come with command-line SSH clients. Follow these steps:

  1. Open up a terminal (located in /Applications/Utilities on the Mac).
  2. Type in the following command, but replace [IP address] with the particular IP address of your Pi that we found out previously:
    $ ssh pi@[IP address]
    

    If your network provides a convenient local DNS service, you might be able to type raspberrypi instead of the IP address try it and see whether it works.

  3. The first time you connect to the Pi or any foreign system over SSH, you'll be prompted with a warning and a chance to verify the remote system's RSA key fingerprint before continuing. This is a security feature designed to ensure the authenticity of the remote system. Since we know that our Pi is indeed our Pi, select Yes to trust this key and continue the connection.
  4. Type the password of the user pi that you chose earlier with raspi-config.
  5. You're now logged in as the user pi. When you've had enough pranking for the day, type exit to quit your SSH session.

The importance of a sneaky headless setup

You might be wondering why we bother with SSH and typing stuff in the command line at all when Raspbian comes with a perfectly nice graphical desktop environment and a whole repository of GUI applications. Well, the first reason is that we need all the CPU power we can get out of the Pi for our projects. With the current graphics drivers for X (the graphics system), the desktop eats up too much of the Pi's resources and the CPU is more concerned with redrawing fancy windows than with running our mischievous applications.

The second reason is that of stealth and secrecy. Usually, we want to be able to hide our Pi with as few wires running to and fro as possible. Obviously, a Pi hidden in a room becomes a lot more visible if someone trips over a connected monitor or keyboard. This is why we make sure all our pranks can be controlled and triggered from a remote location.

Keeping your system up-to-date

A community effort such as Raspbian and the Debian distribution on which it is based is constantly being worked on and improved by hundreds of developers every day. All of them are trying hard to make the Pi run as smoothly as possible, support as many different peripherals as possible, and to squish any discovered software bugs.

All those improvements come to you in the form of package and firmware updates. To keep your Raspbian OS up to date, you need to know the following three commands:

  • sudo apt-get update: This fetches information about what packages have been updated.
  • sudo apt-get dist-upgrade: This proceeds to install the updated packages. Select Yes when prompted for installation.
  • sudo rpi-update: This upgrades to the latest firmware from the Raspberry Pi Foundation's GitHub repository (an online source code management service).

The firmware updates are more related to the Raspberry Pi hardware and may contain improvements to the Linux kernel, new drivers for USB gadgets, or system stability fixes.

Backing up your SD card

It happens to everyone at one point or another—you've put hours into perfecting your Raspbian installation, setting up applications, and hacking away at clever code when out of nowhere your cat/dog/next-of-kin swoops down on your keyboard and triggers the self-destruct mechanism from the Erasing the Pi should it fall into the wrong hands section in Chapter 5, Taking Your Pi Off-road.

Not to worry Agent, backing up an SD card is quite simple as long as you've got the required disk space to store it.

Complete SD card backup in Windows

We'll be making a complete mirror image of your SD card. The data will be stored in a single file that will be the same size as that of your SD card.

  1. Power off your Pi safely and move the SD card to your computer's card reader.
  2. Visit http://sourceforge.net/projects/win32diskimager/ and download the latest version of the Win32 Disk Imager application (Win32DiskImager-0.9.5-install.exe at the time of writing).
  3. Install the application by running the installer.
  4. Start Win32DiskImager from the shortcut in your Start menu.
    Complete SD card backup in Windows

    Backing up an SD card in Windows

  5. Ensure that the correct volume of your SD card is shown under Device.
  6. Click on the folder icon and navigate to the folder where you'd like to store the image.
  7. Enter a good file name for your image and click on Open. The standard file extension for image files is img.
  8. Finally, after verifying that the full Image File path looks good, click on Read.

Once your image backup has completed successfully, you can compress it to save quite a bit of disk space. Just right-click on the image file and select Send to, then click on Compressed (zipped) folder.

To restore your SD card from a backup image, simply point Win32 Disk Imager to your image file, and click on the Write button.

Tip

Win32 Disk Imager is also used to write the operating system images available for download at http://www.raspberrypi.org/downloads directly to the SD card without using NOOBS.

Complete SD card backup in MAC OS X

We'll be making a complete mirror image of your SD card. The data will be stored in a single compressed file, which should result in a smaller size than that of your SD card. The steps to be followed for a data backup are:

  1. Power off your Pi safely and move the SD card to your computer's card reader.
  2. Open up a terminal (located in /Applications/Utilities on the Mac).
  3. Type diskutil list to obtain a readout of all connected storage devices.
  4. To correctly identify your SD card, we're looking for a disk that has at least one Windows and one Linux entry under TYPE (there will be two of each type if we installed Raspbian through NOOBS).
  5. Take note of that disk's first IDENTIFIER field (disk1 in the screenshot).
  6. As a security precaution, we will first unmount the SD card so that no applications running in the background can change data as we make our backup. Use the following command, but replace [disk] with the IDENTIFIER field of your SD card:
    $ diskutil unmountdisk [disk]
    
  7. Now we'll do a complete copy of the SD card and store it in a file called agent_sdcard.img.gz on your desktop. Type the following command, but replace [disk] with the IDENTIFIER field of your SD card (note the letter r in front of disk):
    $ sudo dd if=/dev/r[disk] bs=4m | gzip > ~/Desktop/agent_sdcard.img.gz
    
  8. You might be asked to input your user password so that sudo is allowed to start. The backup process doesn't produce much output as it runs, but a status report can be produced by pressing Ctrl + T in the Terminal window.
    Complete SD card backup in MAC OS X

    Backing up an SD card in Mac OS X

To restore your SD card from a backup image, repeat the previous steps but use this command instead at step 7:

$ gzip -dc ~/Desktop/agent_sdcard.img.gz | sudo dd of=/dev/r[disk] bs=4m

Note

If you type the wrong disk you could potentially overwrite your Mac's internal hard drive without any warning. Do triple check!

Tip

The restore image method is also used to write the operating system images available for download at http://www.raspberrypi.org/downloads directly to the SD card without using NOOBS.

Complete SD card backup in Linux

We'll be making a complete mirror image of your SD card. The data will be stored in a single compressed file, which should result in a smaller size than that of your SD card.

  1. Power off your Pi safely and move the SD card to your computer's card reader.
  2. Open up a terminal.
  3. Type sudo lsblk -f to obtain a readout of all connected storage devices.
  4. To correctly identify your SD card, we're looking for a disk that has at least one vfat and one ext4 entry under FSTYPE (there will be two of each type if we installed Raspbian through NOOBS).
  5. Take note of that disk's NAME (sdb in the screenshot).
  6. If any of the partitions under your disk's NAME have a MOUNTPOINT listed, you should unmount it first. Use the following command, but replace [mountpoint] with the mountpoint of your partition:
    $ sudo umount [mountpoint]
    
  7. Now we'll do a complete copy of the SD card and store it in a file called agent_sdcard.img.gz in your home directory. Type the following command, but replace [disk] with the NAME of your SD card:
    $ sudo dd if=/dev/[disk] bs=4M | gzip > ~/agent_sdcard.img.gz
    
  8. The backup process doesn't produce much output as it runs, but a status report can be produced by typing sudo pkill -USR1 dd in another terminal console.
    Complete SD card backup in Linux

    Backing up an SD card in Linux

To restore your SD card from a backup image, repeat the previous steps but use this command instead at step 7:

$ gzip -dc ~/agent_sdcard.img.gz | sudo dd of=/dev/[disk] bs=4M

Note

If you type the wrong disk you could potentially overwrite your computer's internal hard drive without any warning. Do triple check!

Tip

The restore image method is also used to write the operating system images available for download at http://www.raspberrypi.org/downloads directly to the SD card without using NOOBS.

Summary

In this chapter, you took a look at the different parts of the Raspberry Pi board and learned a bit about how it came to be. You also learned about the importance of a good power supply and how a powered USB hub can help alleviate some of the power drain caused by hungry USB peripherals.

We then gave the Pi an operating system to run by downloading NOOBS to help us install Raspbian onto our SD card. Raspbian was booted and configured with the raspi-config utility. You also learned a few helpful Linux commands and how to set up remote connections from SSH clients over the network.

Finally, you learned how to keep Raspbian up to date and how to create a complete backup image of your precious SD card.

In the upcoming chapter, we'll be connecting sound gadgets to the Pi and getting our feet wet in the big pond of spy techniques.

Left arrow icon Right arrow icon

Description

This book is an easy-to-follow guide with practical examples in each chapter. Suitable for the novice and expert alike, each topic provides a fast and easy way to get started with exciting applications and also guides you through setting up the Raspberry Pi as a secret agent toolbox.

Who is this book for?

This book is an easy-to-follow guide with practical examples in each chapter. Suitable for the novice and expert alike, each topic provides a fast and easy way to get started with exciting applications and also guides you through setting up the Raspberry Pi as a secret agent toolbox.
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 27, 2015
Length: 206 pages
Edition : 2nd
Language : English
ISBN-13 : 9781784397906
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Jan 27, 2015
Length: 206 pages
Edition : 2nd
Language : English
ISBN-13 : 9781784397906
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 70.97
Penetration Testing with Raspberry PI
€24.99
Raspberry Pi Sensors
€24.99
Raspberry Pi for Secret Agents - Second Edition
€20.99
Total 70.97 Stars icon

Table of Contents

6 Chapters
1. Getting Up to No Good Chevron down icon Chevron up icon
2. Audio Antics Chevron down icon Chevron up icon
3. Webcam and Video Wizardry Chevron down icon Chevron up icon
4. Wi-Fi Pranks – Exploring Your Network Chevron down icon Chevron up icon
5. Taking Your Pi Off-road Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(14 Ratings)
5 star 71.4%
4 star 7.1%
3 star 0%
2 star 7.1%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




AT Jan 13, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent Stuff Indeed!
Amazon Verified review Amazon
Mr. Alexander Knox Nov 11, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great read. Just waiting for my Pi to arrive so I can use in earnest
Amazon Verified review Amazon
Manly Geek Oct 30, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Made the Raspberry Pi fun to explore. I bought my first picture via pre-order but only now want to get it out and play.
Amazon Verified review Amazon
Niel Apr 05, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
My kids love these cool Pi projects.
Amazon Verified review Amazon
Amazon Customer Jul 21, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Let me state for the record that I am not a secret agent and have no affiliation with any security service, so I'm unable to assess this book in terms of its application in the world of espionage and covert operations - but, as a maker, hacker, nerd, techie, experimenter, perfectly normal guy who likes playing with electronics (description varies depending upon who you talk to) I can happily say that this is a very, very good and useful book if you want to do interesting things with Raspberry Pi.From the basic setting-up of the Pi it moves to audio and covers, more or less everything you're likely to want. Then on to video, adding the Pi Camera, recording video, playing video, motion detection, multiple cameras, video on the Internet, automated operation – it's all there.Got WiFi and want to dig around in it, control access to it, do more with it and don't want to get bogged down in really deep technical stuff? Yep, that's included too and goes as far as encrypted messaging – in the most understandable application I've ever seen.This book even covers the things that everyone else seems to take for granted – enclosures and battery power for a self-contained Pi (what good is a secret agent in search of a power outlet?).On a technical level this book is excellent and it's very, very readable – well worth buying and enjoying. (but you didn't hear that from me – OK?)
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela