How to set up and configure Ubuntu in Raspberry Pi

Updated: January 28, 2024 By: Guest Contributor Post a comment

Introduction

Setting up Ubuntu on a Raspberry Pi can breathe new life into this compact and versatile computing platform. With Ubuntu, you gain access to a wider range of software and services that can enhance your Pi experience. This tutorial will guide you through the process of setting up and configuring Ubuntu on your Raspberry Pi, from downloading the image to getting your system up and running.

Prerequisites

  • A Raspberry Pi (2, 3, 4, or 400)
  • MicroSD card (at least 8GB recommended)
  • MicroSD card reader
  • Another computer to prepare the SD card
  • Internet connection
  • Power supply
  • Keyboard, Mouse, and Monitor for setup

Step-by-Step Instructions

Step 1: Download Ubuntu for Raspberry Pi

Navigate to the official Ubuntu website at ubuntu.com/download/raspberry-pi and download the appropriate Ubuntu Server image for your Raspberry Pi model.

wget https://cdimage.ubuntu.com/releases/20.04/release/ubuntu-20.04.2-preinstalled-server-arm64+raspi.img.xz

Step 2: Flash Ubuntu Image onto the MicroSD Card

To flash the image, use the Balena Etcher software or any other image flashing tool. If you are on Linux, you can use the dd command:

sudo dd if=ubuntu-20.04.2-preinstalled-server-arm64+raspi.img.xz of=/dev/sdx bs=4M status=progress

Make sure to replace /dev/sdx with the correct device path of your SD card.

Step 3: Initial Boot and Configuration

After flashing, insert the microSD card into your Raspberry Pi and connect it to power, monitor, keyboard, and mouse. On boot, follow the on-screen instructions to complete the initial setup, including setting the locale, timezone, and user accounts.

Step 4: Network Configuration

Connect your Raspberry Pi to the internet via Ethernet or WiFi. For WiFi configuration, use the nmtui command to access the Network Manager.

sudo nmtui

Connect to your network by navigating the menu and following the prompts.

Step 5: Update and Upgrade

Once connected to the internet, update and upgrade the system to get the latest packages and security updates:

sudo apt update && sudo apt upgrade -y

Step 6: Installing a Desktop Environment

If you require a graphical interface, install a desktop environment:

sudo apt install ubuntu-desktop

This will install the GNOME desktop environment, setting up a more familiar computing experience.

Step 7: Configure SSH for Remote Access

To manage your Raspberry Pi remotely, configure SSH:

sudo systemctl enable ssh
sudo systemctl start ssh

You can then connect to your Pi from another computer using:

ssh [your_user]@[your_pi_ip_address]

Step 8: Additional Configurations and Software

Configure additional settings using the raspi-config tool and install any required software with:

sudo raspi-config
sudo apt install [software-name]

Advanced Setup

For more advanced users, configure a static IP, set up a web server, or deploy containers using Docker:

# Set a static IP
echo "interface eth0\nstatic ip_address=192.168.1.100/24\nstatic routers=192.168.1.1\nstatic domain_name_servers=192.168.1.1" | sudo tee -a /etc/dhcpcd.conf

# Install a Web Server
sudo apt install apache2 -y

# Deploy Docker
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker

Conclusion

In this tutorial, we’ve covered the essentials of setting up and configuring Ubuntu on your Raspberry Pi. This setup creates a powerful development environment or a versatile platform for computing projects.