Sling Academy
Home/DevOps/How to set up and configure Ubuntu in Raspberry Pi

How to set up and configure Ubuntu in Raspberry Pi

Last updated: January 28, 2024

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.

Next Article: How to switch users in Ubuntu

Previous Article: Linux Permissions: The Ultimate Cheat Sheet

Series: Linux Tutorials

DevOps

You May Also Like

  • How to reset Ubuntu to factory settings (4 approaches)
  • Making GET requests with cURL: A practical guide (with examples)
  • Git: What is .DS_Store and should you ignore it?
  • NGINX underscores_in_headers: Explained with examples
  • How to use Jenkins CI with private GitHub repositories
  • Terraform: Understanding State and State Files (with Examples)
  • SHA1, SHA256, and SHA512 in Terraform: A Practical Guide
  • CSRF Protection in Jenkins: An In-depth Guide (with examples)
  • Terraform: How to Merge 2 Maps
  • Terraform: How to extract filename/extension from a path
  • JSON encoding/decoding in Terraform: Explained with examples
  • Sorting Lists in Terraform: A Practical Guide
  • Terraform: How to trigger a Lambda function on resource creation
  • How to use Terraform templates
  • Understanding terraform_remote_state data source: Explained with examples
  • Jenkins Authorization: A Practical Guide (with examples)
  • Solving Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap
  • Understanding Artifacts in Jenkins: A Practical Guide (with examples)
  • Using Jenkins with AWS EC2 and S3: A Practical Guide