# 02. Installing Ubuntu Server

We're going to start on our main computer (not the Pi)

First you'll need to download Ubuntu Server. To do this I prefer to use the rpi-imager tool. Install this by typing: `sudo snap install rpi-imager`

Once installed, click:\
\
`Choose OS > Other general purpose OS > Ubuntu > Ubuntu Server 20.04.3 LTS`

Insert your SD card in your computer/hub/whatever and click `Choose Storage` and select the card.

Click `Write` and rpi-imager will download the OS and flash it to the SD card.

Super easy, cool.

1. Make sure you have a keyboard/monitor plugged in to your Raspberry Pi.
2. Insert the SD card in to the Pi and connect the power.

From ubuntu.com:

> Warning During your first boot a tool called cloud-init is doing configuration. WAIT for it to finish before trying to log in. It typically takes less than 2 minutes but there is a break between the log-in prompt and cloud-init completing. If you interrupt the process you have to start again. You’ll know it’s done when it outputs some more lines after the log-in prompt has appeared.

1. Once all that is taken care of, login with the username `ubuntu` and password `ubuntu`
2. You will be asked to update the password for the ubuntu user. Do that.
3. If your Pi is connected to the internet with an ethernet cable and the internet isn't working, try typing `sudo dhclient eth0`
4. If you're going to use wifi we need to make an edit to a file on the system

`sudo nano /etc/netplan/50-cloud-init.yaml`

make this file look like this with the **exact** indenting (4 spaces)

```yaml
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            dhcp4: true
            optional: true
            access-points:
                "SSID_name":
                    password: "WiFi_password"
```

Then save and exit `Ctrl + O`, `Enter` `Ctrl + X`

1. Generate some stuff with `sudo netplan generate`
2. Apply that stuff `sudo netplan apply`
3. Reboot the Raspberry Pi: `reboot`
4. Once it starts up again, check to see if you're connected to the internet `ip a` and in the section `wlan0` you should see your local ip address, something like `192.168.X.XXX`
5. Update everything: `sudo apt update && sudo apt upgrade`&#x20;

&#x20;   If that last command gave you an error:

1. Try running `sudo apt update` and then when it's done run `sudo apt upgrade`
2. Reboot: `reboot` and try the commands again.
