AWS Lightsail upgrade Ubuntu 16.04 LTS to 18.04 LTS nixCraft

By default, Lightsail will install Ubuntu 16.04 LTS. How do I upgrade to Ubuntu Linux 18.04 LTS when using AWS Lightsail cloud server? How do I upgrade to a newer version of Ubuntu such as Ubuntu Linux 18.04 LTS?

Ubuntu team recommend upgrading a Server Edition installation by using the do-release-upgrade command. Part of the update-manager-core package, it does not have any graphical dependencies and is installed by default. This page shows how to use the recommended upgrade method for AWS Lightsail box powered by Ubuntu Linux 16.04 LTS.

AWS Lightsail upgrade Ubuntu 16.04 LTS to 18.04 LTS

The procedure to upgrade Ubuntu 16.04 LTS to 18.04 LTS is as follows for AWS Lightsail server:

Step 1. Login to AWS Lightsail box

Use the ssh command:
$ ssh -i ~/path/to/your-key ubuntu@aws-ip-address
Connect using your own SSH client

Step 2. Update existing system

Type the apt-get command or apt command:
$ sudo apt update
$ sudo apt upgrade

Reboot the Linux box if kernel was updated
$ sudo reboot
After reboot makes sure either UFW firewall is temporarily disabled or TCP port 1022 is open. One could use the TCP port 1022 during upgrade procedure if something went wrong. The following command can verify if any software firewall is working on your system or not:
$ sudo iptables -L -n -v
ufw iptables verify firewall
I have no firewall running on my box. However, if you have a firewall running, open ssh port 1022 using the following ufw syntax:
$ sudo ufw allow 1022/tcp comment 'Temp open port ssh tcp port 1022 for upgrade'

Step 3. How to upgrade to Ubuntu 18.04 LTS using do-release-upgrade

Upgrade the operating system to the latest release from the command-line by typing the following command:
$ sudo do-release-upgrade
How to upgrade Ubuntu operating system to latest release
Before continuing with the procedure, you must open port TCP port # 1022 for safety reasons if port ssh failed during updates. Login to aws lightsail console, click on the networking tab and open port 1022 as follows:
AWS Lightsail open port 1022 for Ubuntu upgrade
Now follow on-screen instructions. During upgrade procedure, you may be promoted to replace existing grub or ssh config file. Make sure you choose to keep existing version to avoid problems. After some time you will see “System upgrade is complete” message. Press y to restart your system to load updates kernel and operating system for your cloud server:
Ubuntu system upgrade is complete. Restart required for aws lightsail

Step 4. Verification for AWS Lightsail instance

Login using the ssh command:
$ ssh -i ~/path/to/your-key ubuntu@aws-ip-address
AWS Lightsail upgrade Ubuntu 16.04 LTS to 18.04 LTS upgrade completed
Verify Ubuntu Linux kernel version with uname:
$ uname -r
Make sure all needed ports are open and running with the ss command or netstat command:
$ sudo ss -tulpn
$ sudo netstat -tulpn

Use grep command/egrep command or tail command/cat command to verify log files for errors:
$ dmesg
$ tail -f /path/to/log/files
$ egrep -i 'err|cri' /var/log/nginx/error.log

Step 5. Remove tcp port 1022 added to AWS Lightsail instance/networking

Login to AWS Lightsail, choose networking and edit rules link:
Remove SSH port 1022 part 1
Remove custom TCP 1022 rule and click on the save button/link:
Remove SSH port 1022 part 2
Finally, remove ufw rule if added:
$ sudo ufw delete allow 1022/tcp


And there you have it Ubuntu Linux 16.04 LTS updated to Ubuntu 18.04 LTS running on AWS Lightsail cloud. See this page for more info.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Facebook Comments

More Stuff

Top open source projects in 2018, open source hardware, donation m... In this edition of our open source news roundup, we take a look at GitHub and its efforts to protect open source in the EU, a novel idea for sustainab...
Regular Expressions In grep examples nixCraft Updated Tutorials/Po... How do I use the grep command with regular expressions on a Linux and Unix-like operating systems? How do I use grep and regular expressions to searc...
Ansible reboot a Debian/Ubuntu Linux for kernel update and wait fo... How can I reboot a Debian or Ubuntu Linux server/host remotely using an Ansible playbook for kernel update and wait for it to come back again?Introdu...
How to Install LAMP (Linux, Apache, MariaDB and PHP) on Fedora 23 ... If you ever wanted to host your own website or just want to try your PHP programming skills, you will most definitely have stumbled upon LAMP. For tho...
Spread the love

Posted by News Monkey