CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > DevOps > How to Upgrade AWS EC2 Ubuntu Version: A Step-by-Step Guide

How to Upgrade AWS EC2 Ubuntu Version: A Step-by-Step Guide

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: November 20, 2024 · 2 min read · 0 Comments
Share: in X

Upgrading the Ubuntu version on an AWS EC2 instance involves several steps to ensure a smooth transition. Follow this guide to upgrade your AWS EC2 Ubuntu version safely.

Table of Contents

  • Prerequisites
  • Step 1: Connect to Your EC2 Instance
  • Step 2: Update Current Packages
  • Step 3: Clean Up Unnecessary Packages
  • Step 4: Check the Current Ubuntu Version
  • Step 5: Upgrade to the New Ubuntu Version
  • Step 6: Reboot the Instance
  • Step 7: Verify the Upgrade
  • Troubleshooting
  • Conclusion

Prerequisites

  • An AWS EC2 instance running Ubuntu.
  • SSH access to the instance.
  • A backup of your instance or important data.

Step 1: Connect to Your EC2 Instance

First, connect to your EC2 instance using SSH:

ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns

Or you can use SSH client like Putty.

Step 2: Update Current Packages

Before upgrading, ensure that all current packages are up-to-date:

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y

Step 3: Clean Up Unnecessary Packages

Remove any unnecessary packages to free up space:

sudo apt-get autoremove -y
sudo apt-get clean

Step 4: Check the Current Ubuntu Version

Verify the current Ubuntu version:

lsb_release -a

You may see an output like this:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

Step 5: Upgrade to the New Ubuntu Version

Start the upgrade process to the new Ubuntu version. For example, to upgrade from Ubuntu 18.04 to 20.04:

sudo do-release-upgrade

Follow the on-screen instructions to complete the upgrade. You may need to confirm some prompts during the process.

Step 6: Reboot the Instance

After the upgrade is complete, reboot your instance:

sudo reboot

Step 7: Verify the Upgrade

Once the instance has rebooted, reconnect via SSH and verify the new Ubuntu version:

lsb_release -a

After the successfully update you may see the output like below:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Troubleshooting

If you encounter any issues during the upgrade, check the logs for more details:

sudo less /var/log/dist-upgrade/main.log

Conclusion

Upgrading the Ubuntu version on an AWS EC2 instance is a straightforward process if you follow these steps. Always ensure you have a backup before starting the upgrade to prevent data loss.

By following this guide, you can successfully upgrade your AWS EC2 Ubuntu version.

Related Posts:

  • How to Connect Java Application to a Remote Database…
  • How to Fix SSH Agent Forwarding on macOS: The…
  • How to Solve “systemctl command not found” Error: A…
  • How to Login/SSH to AWS EC2 linux instance?
  • Install MongoDB BI Connector on Ubuntu
  • Connect To MongoDB using Compass Via SSH Tunnel
Tags:awsdevopsubuntu
Was this article helpful?
← Previous ArticleHow to Accept List of IDs as Request Parameters in Spring Boot
Next Article →How to Connect MongoDB Atlas Using Compass – Step-by-Step Guide

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap