DEV Community

Samuel Beard
Samuel Beard

Posted on

Raspberry Pi & Raspbian setup as fast as possible

This is a simple setup guide to install Raspbian on a Raspberry Pi and get it set up headlessly. This means that we we won't ever need to plug a keyboard, mouse or screen into it.

This is a tutorial for MacOS and Linux because it makes use of the terminal. If there is demand, I will write a Windows specific version.

Make sure you have these things:

  • Your Raspberry Pi
  • A way to power your Raspberry Pi
  • A micro SD card
  • A micro SD card adapter so you can plug it into your computer
  • A computer
  • If your Pi doesn't have WiFi built in, you'll need a WiFi dongle.

Wifi is built in to the Raspberry Pi Zero W and Raspberry Pi 3 and on.

Download these things:

Let's carry on with the tutorial assuming you have everything installed and downloaded.

Installing Rasbian

  1. Unzip the Rasbian zip folder that you downloaded. There should be a .img file in there.
  2. Using your USB adapter, plug in your micro SD card to your computer.
  3. Open Etcher on your computer.
  4. Select the .img Rasbian file in the left section.
  5. Select the micro SD card in the middle section.
  6. Click "Flash" and wait.

Once that is done, Rasbian is installed.

By default, Rasbian disallows ssh connections. So we will need to enable them. Also, we want the Pi to be able to connect to our WiFi right away so we don't need to connect a screen and keyboard to it.

Enable SSH over Wifi

  • If the micro SD card has unmounted from your computer, reconnect it.
  • In the Terminal, go to the SD card.
# Mac
cd /Volume/MySDCard/
# Linux (Can vary or require additional steps)
cd /media/MySDCard/
Enter fullscreen mode Exit fullscreen mode
  • Add a blank file simply called ssh to the micro SD card.
$ touch ssh
Enter fullscreen mode Exit fullscreen mode
  • Add a file called wpa_supplicant.conf to the micro SD card.
nano wpa_supplicant.conf
Enter fullscreen mode Exit fullscreen mode

This file needs to contain your WiFi name and password. Here is a template you can edit.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}
Enter fullscreen mode Exit fullscreen mode
  • Once these two files are on your SD card, remove it and plug it into your Raspberry Pi.
  • If the PI needs a Wifi adapter, plug it in. Then power up the Pi.

The only cable you need to have plugged into the Pi is the power cable.

Find Your Pi's IP Address

You can do this by simply looking at your routers UI. Just find the device called 'Raspberry Pi'.

If you want to find the IP in the terminal:

arp -na | grep -i b8:27:eb
Enter fullscreen mode Exit fullscreen mode

This will give you an IP address starting with '192.168.'. That's your Pi's internal IP address. You can only access your Pi from another device on the same network using this address.

All Raspberry Pi device MAC addresses start with 'B8:27:EB'.

Access and Setup

  • SSH onto your Pi
sh pi@192.168.x.x
Enter fullscreen mode Exit fullscreen mode

Replace the Xs with your Pis IP address.

  • When asked for a password, type 'raspberry'. It will look like nothing is being typed. Don't worry, it is.

  • The first thing we want to do here is to change that default password.

passwd
Enter fullscreen mode Exit fullscreen mode
  • Update
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

You are all set and ready to go! Just use your new password when SSHing to the Pi from now on.


If you have questions, feel free to ask.

You can also check out the Raspberry Pi Stack Exchange

Top comments (0)