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:


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

version: 2
renderer: networkd
    dhcp4: no
addresses: [,,,]

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:


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:

# /etc/rc.local

/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 > /etc/hostname
# vim /etc/hosts

And add the new hostname including the IP address (in this case  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.