Setting up your Raspberry PI 4 - Headless mode
Tags: raspberrypi, iot, tutorial
Published: 2020-03-31 01:25:50

---
title: Setting up your Raspberry PI 4 - Headless mode
published: true
date: 2020-03-31 01:00:00 UTC
tags: raspberrypi, iot, tutorial
cover_image: https://sahansera.dev/static/e36870ff71d11e114437a90202a903c7/b303b/setting-up-raspberry-pi-4-headless-mode.webp
canonical_url: https://sahansera.dev/setting-up-raspberry-pi-4-headless-mode/
---

When I first got my Raspberry PI 4 (_RPI_ for the rest of the article), I was so excited to get started. However, there was one problem. How do I get started? To make matters worse it only had 2 micro-HDMI ports and I couldn’t connect it to a monitor. After a while I found myself wading through link after link.

I am going to show you what worked best for me and a recipe you can also use to get started with your RPI 4 quickly - without an external monitor 🙂

### Specs

![1-rpi.png](https://sahansera.dev/static/bd7982b51895d08f77ca21165ffa766c/71275/1-rpi.png)

Source: [https://www.raspberrypi.org/products/raspberry-pi-4-model-b/](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/)

### Step 1 - Installing an OS

My choice of OS for the RPI is [Raspbian](https://www.raspberrypi.org/downloads/raspbian/) since it’s easy to get started with and comes with a lot of tools out of the box. I would recommend selecting “with Desktop” option if you are planning to use it with a window manager.

![2-raspbian.jpg](https://sahansera.dev/static/92a678a7b9fa6b185e7456eebeda2eee/f67cc/2-raspbian.jpg)

Once you have got the ISO downloaded we need to flash it to a microSD card. I used [balenaEtcher](https://www.balena.io/etcher/) since it was pretty straight forward to use.

![3-balena.png](https://sahansera.dev/static/d4d95e78c14e00b776633a680f84ed3e/11d19/3-balena.png)

If you are using Windows, it will ask you to format the drive when opened with Windows Explorer. **Don’t do that 😀** Otherwise, you will find yourself doing this step over and over again.

Now, open the microSD drive in your Windows Explorer or Finder. For us to be able to connect via ssh later, we need to create an empty file called `ssh` at the root of the drive (without any extension).

![4-ssh.png](https://sahansera.dev/static/b4238449b115dbe8af80fda1d061f8bc/11d19/4-ssh.png)

Safely eject, unplug the microSD card and chuck the microSD card in to the RPI’s slot.

### Step 2 - Connecting the RPI to LAN

This is going to be a one-off step. We need to connect the RPI to the router with an ethernet cable (RJ45) and boot it up. Give it a minute to settle down.

After that, we need to find the local IP of our RPI for us to be able to SSH into it. Normally you can head over to `192.168.1.1` or [routerlogin.net](http://routerlogin.net) if you are using a NETGEAR router.

You need to find the connected list of devices of your router. Now, copy the IP of your RPI

### Step 3 - SSH in to your RPI (Headless mode)

You can wither use [PuTTY](https://www.putty.org/) if you are on windows or your terminal on a \*nix system.

`ssh pi@your_rpi_local_ip`

In default settings, the password would be just `raspberry`

![./5-rpi-ssh-2.png](https://sahansera.dev/static/60ccf64567f2fc8230f09588c8c28788/11d19/5-rpi-ssh-2.png)

There’s only a single step remaining to get in to your RPI’s desktop environment.

### Step 4 - Connecting to RPI with VNC

Now that you know how to ssh into the RPI, we need to use it in GUI mode. We are going to use a VNC provider for that. VNC is a graphical desktop sharing system that allows us to remotely control the desktop interface of our RPI (running VNC Server) from another computer or mobile device (running VNC Viewer).

While you are connected your RPI, let’s run the following commands in the terminal

```
  sudo apt update
  sudo apt install realvnc-vnc-server realvnc-vnc-viewer
```

You can enable VNC Server at the command line using [raspi-config](https://www.raspberrypi.org/documentation/configuration/raspi-config.md):

```
  sudo raspi-config
```

![./6-rpi-config.png](https://sahansera.dev/static/c4941a1f6bcb50adc44073550e6f3d5b/11d19/6-rpi-config.png)

Now, enable VNC Server by doing the following:

- Navigate to  **Interfacing Options**.
- Scroll down and select  **VNC > Yes**.

![./7-rpi-vnc.png](https://sahansera.dev/static/b558e929cb12bd4e7af4e0887937e176/11d19/7-rpi-config-2.png)

For our changes to take effect, let’s reboot the RPI

```
  sudo reboot
```

While it’s rebooting, let’s download the [RealVNC viewer](https://www.realvnc.com/en/connect/download/viewer/),

Once the viewer is installed on your local machine, let’s open it up and enter the IP address of your RPI, username & password.

![./8-rpi-vnc-2.png](https://sahansera.dev/static/fb63696dd8c2aa81015a45bdf9a7bf34/11d19/8-rpi-vnc-2.png)

Don’t forget to connect the RPI to your home’s Wifi network. **Now you can unplug the RJ45 from the RPI and keep it anywhere you want**.

![./9-rpi-desktop.png](https://sahansera.dev/static/a21eff908e935ad3bed8f31b80e1bb9f/11d19/9-rpi-desktop.png)

Hope this article helped you. In my next article, we will see how you can configure your own Kubernetes cluster on your RPI!

Enjoy your new Raspberry PI 🥧

### References

1. [https://www.raspberrypi.org/documentation/remote-access/vnc/](https://www.raspberrypi.org/documentation/remote-access/vnc/)
2. [https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0](https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0)
3. [https://www.imore.com/how-take-screenshot-raspberry-pi](https://www.imore.com/how-take-screenshot-raspberry-pi)