In this article I’ll show you how to get started with Raspberry Pi. At it’s simplest, a Raspberry Pi is simply a low-cost computer used by millions of people globally for programming and/or low-end computing. The Pi can be used simply as a basic, low-cost desktop PC with full browser functionality, or in an array of multiple units to perform high-end computing.
Once you have mastered the basics, you’ll be able to move on to more “complicated” projects with the Pi. As an example, I use a few pis to run my home automation, an ad-blocker, and an apache forward/reverse proxy server. Honestly, I mean complicated in the loosest sense because there are people doing some crazy things with Pis. We’ll assume you’re starting from scratch (like I did) and know absolutely nothing about the Raspberry Pi.
What is Raspberry Pi?
If you want to know the full story behind the Raspberry Pi, head over to Raspberrypi.org. Surprisingly, Raspberry Pi is a charity-based foundation with the sole purpose of improving computing access and knowledge. Specifically, the foundation targets young people to teach them the basics of computing, programming, and digital skills. Since the premise of the foundation is to provide low-cost computers for learning, their products are remarkably inexpensive in comparison to large brand names such as Microsoft, Dell, or Apple.
Because the foundation is a charity, and because the goal is for low-cost computing, the operating system is Linux-based. If you haven’t heard of Linux, its an open-source, free to us operating system. There are several variants of Linux, including Raspbian. You can install other OS’s (i.e. Ubuntu), the Raspbian OS is specifically designed to run on all Pi models.
Comparison of Raspberry Pi models
|Pi Zero||Pi Zero W||Pi 1 A+||Pi 1 B+||Pi 2 B||Pi 3 B||Pi 3 B+||Pi 3 A+||Pi 4 B|
|CPU||ARMv6Z 32-bit||ARMv6 32-bit||ARMv6 32-bit||ARMv6Z 32-bit||ARMv7 32-bit Quad 900MHz||ARMv8 64-bit Quad 1.2GHz||ARMv8 64-bit Quad 1.4GHz||ARMv8 64-bit Quad 1.4GHz||ARMv8 64-bit Quad 1.5GHz|
Linux versus Windows
Since the Pi runs on a Linux-based OS, it’s only fitting I touch on some differences compared to Windows. I can’t speak to Mac, since I don’t use the Apple OS. If you are used to a pretty user interface (or GUI), get ready for a small shock. You can use the Linux desktop, but most of what we’re going to do initially is going to run from the command line (or shell).
Probably the most pronounced difference I noticed versus Windows is related to user permissions. In Windows, as long as you are logged in as an administrator you can manipulate files without having to worry about approving each change. With Linux, most changes to system files require root user access. In Windows you “run as administrator” or access with administrator privileges. Generally, in Linux if you don’t have permission as a root user to change or add a file, you can’t do it. With a little practice it gets easier to wrap your head around permission’s structure, eventually.
Basic Linux Operations
Before we really dive in, let’s look at some basic operations. I started without having any clue as to what many of the shell arguments I was typing actually meant. For the most part, I had to figure it out as I went. However, I you want to get a detailed introduction to the command line, I recommend this book by William Shotts. Since this is going to be more focused on getting a Pi up and running, I’ll stick with the basics here.
|sudo||Run command as a root user||sudo mkdir|
|cd||Change directory||cd /usr/bin|
|mkdir||Create directory||mkdir /usr/bin/localfile|
|cp||Copy file/directory||cp /usr/bin/localfile /var/www/html/localfile|
|mv||Move file/directory||mv /usr/bin/localfile /var/www/html/|
|rm||Remove file/directory||rm /usr/bin/localfile|
|rm -r||Remove directory and all subfolders||rm -r /usr/bin/|
|rm -rf||Force remove directory and all subfolders *beast of a command–no takesie backsies*||rm -rf /usr/bin/|
Getting started with Raspberry Pi-Hardware Requirements
Now that the basics are out of the way, here are the items required to get started:
- A Raspberry Pi (model dependent on the application, but generally go with the latest)
- Micro SD card
- Micro SD card reader*
*As of January 2022 an imaging utility is available the can flash the OS directly to the SD card without using a reader and an imager on a different computer
Optional items (but highly recommended):
- For all Pi models I recommend a case to protect the board from accidental damage
- The Pi 4 B can get a little warm so a small fan is a good idea if it will be in a case or enclosed area
- A PoE splitter (if you have a POE switch) so you don’t have to have a separate power cable
- An external USB SSD drive to use instead of a microSD card
If you buy a kit you’ll often end up with everything you need. Both of my Pi boards were purchased through CanaKit and included a case, fan, heat sinks, microSD card, power supply, and mini HDMI cable.
If you plan on running several boards cases are available to mount multiple boards in a small form factor. Amazon and Ebay both have these, as well as rack-mount kits if you have a server rack.
Getting started with Raspberry Pi-Initial Set Up
We’re going to do what is called a “headless” install of our Raspberry Pi. Simply put, a headless install doesn’t have the Pi directly connected to a computer monitor or peripherals. In this install we’re going to set up the Pi as if its just going to only be accessed remotely, and we’ll get as much as possible set up prior to booting the Pi for the first time. If you want to do the traditional method and play with it first you can follow the instructions that come with the kit before coming back to this guide. Of note, we’re going to be using a wired LAN connection to set this up initially.
Setting up the OS
First up, set up your Raspberry Pi. My recommendation is to start with a fresh install without any of the default packages. If you buy the CanaKit version of the Pi, it will come with an SD card that already has Noobs installed (that’s the installer for the basic Pi OS). You’re going to wipe the card and start fresh. To get started, insert the microSD card into the reader and plug it in to an available USB port on a desktop or laptop.
- If using Windows to complete the initial setup, download the Raspberry Pi Imager utility.
- Once downloaded and installed, you will format the micro SD card. Choose “Choose OS” and select “Erase” to format the card as FAT32. Select the the micro SD card and hit “Write”.
- Once the formatting completes, you’ll now need to choose the actual OS we will want to install. Repeat the above step, but instead of formatting, we’re going to go ahead and install an OS. The recommendation is Raspbian, but you can choose from several.
Enable SSH for a “headless” install (skip if connected to a monitor)
To be honest, if you search the web you’ll find that most places will tell you that it is not possible to do a headless install prior to booting the first time. While that is somewhat true, with a little legwork you can enable SSH so that you can access the command line remotely on first boot. This saves you a little bit of work, and a lot of running (especially if your pi is down a flight of stairs like mine). Likewise, in most cases once you set up the Pi, its never going to moved again depending on its function.
The process for this is actually very simple. Before you remove the microSD card from the desktop navigate to it and open it in file explorer. Using notepad, place an empty text file named ssh into the root folder. When you save the text file, rename it (select and hit F2) to “ssh” by deleting the .txt file extension. At this point, you’ve told the OS to enable SSH on boot.
One last step: make sure you have a SSH client downloaded on the PC you will be using to access the Pi. The most common client is PuTTy, which you can download from the Microsoft app store.
Start up and log in
Go ahead and plug the Pi in. While it boots, head back to your PC and start PuTTy (or your SSH client of choice). A quick note here regarding Linux. As already mentioned Linux is very picky about permissions; it is equally as picky with spelling, character spacing, and lowercase/uppercase. Always double-check your command entry before hitting the Enter key; once a command fires you may not be able to take it back.
After giving it a few minutes to start, log in to your Pi with PuTTy. To do so, type the IP address in of the Pi in as the host name, leaving the port at 22. Hit “Open” to start the session. On the first boot, the default username is “pi” with password “raspberry”. Notably, the password is hidden when you type it. We’ll change the default password later. If your not doing a headless install the initial username and password remains the same in the desktop.
It’s important to note that there is no reason to install VNC viewer if you are comfortable with the command line. Everything you do from a desktop view in Linux can also be done from the command line, but if you prefer the more “Windows-like” feel, read on.
Configure the SD card and VNC Viewer
The first thing we need to do is get everything set up for an easier viewer. Generally, you can do everything from the SSH session, but I prefer to use VNC viewer and the Linux desktop since it has a little more familiar feel to Windows. Let’s get started and type
sudo raspi-config to open the config utility:
- First we need to tell the OS to use the entire SD card. By default the imager only uses part of the SD card (2GB). The same is true if you later go on and copy the SD card over to a SSD and boot from USB (which I highly recommend doing, since SD cards can be a bit flakey). Arrow down to Advanced Options, hit enter, and choose option “A1 Expand Filesystem”.
- Next, we want to change our display resolution, otherwise with VNC viewer you will likely encounter a blank screen. From the top menu, choose Display Options, Resolution, and your desktop resolution. Best bet is to go with 1920×1080.
- Last, we want to configure it to be able to use VNC Viewer. So from the top menu choose Interface Options, move to “P3 VNC”, and enable VNC.
- Tab over to “Finish” and reboot if prompted. If not, in the command line type
Download VNC Viewer
Your next task is to download VNC Viewer. This is a remote desktop client that will let you interact with your Pi in a more familiar interface. Once downloaded, start it and go to File>New Connection. Type in the IP address or hostname of your Pi and give it a friendly name (optional). Hit OK and an authentication screen will be shown. Since we left the default password the same, type in “raspberry” for the password and hit OK to open the desktop. As the default user you will need to configure a new password; make it a strong password that is not easy to guess. Go ahead and complete these, including the system update. Once it is complete and your Pi has rebooted, come back to the desktop, using the new password to log in through VNC.
Optional-Use a SSD to boot from USB
MicroSD cards are a bit flakey. Many of the community forums I stalk have stories about their Pi suddenly kicking the bucket, and most of the time it is traced back to a bad microSD card. Fortunately, their is an easy way around this. Raspbian can be instructed to boot from USB, and with that we can boot from a SSD. I picked up a cheap 250GB USB 3.0 SSD from Amazon for $35.
- Make sure the Pi is up to date by running
sudo apt-get updatefollowed by
sudo apt-get upgradefrom the command line.
sudo raspi-configto enter the configuration utility and select “Advanced Options”.
- Arrow down to “A7 Bootloader Version” and make sure that the latest version is selected.
- Make sure using another PC the SSD is formatted to FAT32 before plugging it in to the Pi.
- Next, from the Raspbian applications menu, click “Accessories” and then SD Card Copier.
- Make sure the Copy To Device matches your SSD and check the New Partition UUIDs box before hitting Start
- Finally, go back to the command line and raspi-config. Under Advanced Options select A6 Boot Order and then B1 Boot from USB if SD Card fails.
- Exit out of the configuration utility and type
sudo shutdown. Once powered down unplug the Pi.
- Remove the microSD card from the Pi; store it in a safe place. Plug back in the Pi and allow it to reboot.
The last step is to go back and expand the filesystem to use the full SSD (under Raspi-config, advanced options, expand filesystem).
An alternative to VNC viewer or PuTTy is Webmin. Webmin, while not a desktop environment, is a more friendly user interface that is good for server management. It is also handy if you are running several boards, as you can manage them from one session. For more information, see this article.
And that’s it. You have set up a Raspberry Pi and can access it remotely. Getting started with Raspberry Pi is a rabbit hole, and can result in long hours spent toying around with the thousands of things it can do. See my article on setting up Node-RED for an example of how you can run home automation off a Pi, and stay tuned to see how to host a blog using a Raspberry Pi.