How to install the perfect Ubuntu 20.04 LTS server on Raspberry Pi

To start the installation, download the Raspberry Pi Imager from the official Raspberry Pi website. Insert the SD card (min. 8GB) and select Ubuntu Server 20.04 LTS from the list of the available operating systems. Once the write and verify is complete, insert the SD card in the raspberry pi, connect the HDMI, network cable, and power source.

The default username and password is ubuntu. Change the password on the first login. Once the password is changed, sudo to root and change the root password as well.

# sudo -s
# passwd

Once the password is changed, edit the apt conf file and disable automatic updates installation. Keep the automatic package list update.

# vim /etc/apt/apt.conf.d/20auto-upgrades

Make sure that the configuration is like this:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unnatended-Upgrade "0";

Save and exit.


Install the aptitude package:

# apt-get install -y aptitude

Update the package list:

# aptitude update

Install available updates with dependencies:

# aptitude safe-upgrade

Disable WLAN0 and the Bluetooth:

# vim /boot/firmware/config.txt

Add at the end of the file:

dtoverlay=disable-wifi
dtoverlay=disable-bt

Save and exit.


Disable Cloud-init:

# touch /etc/cloud/cloud-init.disabled

Configure the static IP address:

# vim /etc/netplan/50-cloud-init.yaml

And type in the static IP address. In this case 10.0.0.99

network:
version: 2
renderer: networkd
ethernets:
  eth0:
    dhcp4: no
    address:
     - 10.0.99.99/16
gateway4: 10.0.255.254
nameservers:
addresses: [10.0.254.1, 10.0.254.2, 10.0.255.1, 10.0.255.2]

Save and exit. Apply the configuration:

# sudo netplan apply 

Create another user (in this example user is “keeper”) and fill in all the necessary information:

# adduser keeper

Add the new user to the sudoers:

# visudo

Add at the end of the file

keeper  ALL=(ALL:ALL)  ALL

Save and exit. Logout and log in using a new username. Delete user ubuntu:

# sudo userdel -r -f ubuntu

Disable IPv6 on the pi:

# sudo vim /etc/sysctl.conf

add the following 3 lines at the end of the file:

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

Save and exit. Apply the new configuration:

# sudo sysctl -p

If the IPv6 is still active after the reboot, create the following file:

# sudo vim /etc/rc.local

and add the following:

#!/bin/bash
# /etc/rc.local

/etc/sysctl.d
/etc/init.d/procpc restart

exit 0

Change the permission on the file.

# chmod 775 /etc/rc.local

This will manually read the kernel parameter from the configuration file during boot and disable IPv6.

Change the hostname:

# sudo echo rocket01.sefnet.net > /etc/hostname
# vim /etc/hosts

And add the new hostname including the IP address (in this case 10.0.99.99)

10.0.99.99  rocket01.sefnet.net  rocket01

Disable AppArmor:

# systemctl stop apparmor
# systemctl disable apparmor

The server is ready for use. Now you can install any required package and configure the required function.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.