;

How to update an Ubuntu server using apt-get

Try it in our public cloud & Get $5 Credit
CLAIM NOW

How to update an Ubuntu server using apt-get

Security in the cloud is paramount, and so it’s important to keep your server up to date. If you don’t regularly apply the latest security fixes and patches to your machine, then you run the risk of your server being compromised due to an easily preventable exploit.

When you’re running Ubuntu, the primary method to keep your server updated is by using apt-get, a package manager included with Ubuntu. apt-get makes it easy to grab the latest updates to any installed package.

Getting Started

Confirm that you have the following before you follow this guide:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu.

Additionally, it’s important to remember to backup your server and data on a regular basis, especially before making any substantial updates or upgrades to your system.

Tutorial

Basic commands

apt-get has a number of subcommands that you may find useful during server administration tasks. The following are the most common ones that you’ll use.

apt-get update
This command will inform your system of the latest packages extant in the repository. It downloads all lists of packages from any repositories installed on your system and then uses them to update your local copy. This will give your system information on the newest versions of packages and their dependencies.

apt-get upgrade
This command is the simplest way to update your system. It will check your package lists and download any detected new versions of packages existing on the machine. One caveat is that you have to have used apt-get update first.

apt-get dist-upgrade
Similar to the above, except this command will also intelligently handle dependencies. It has the ability to remove obsolete packages and add new ones.

Before you upgrade, apt-get will show all the packages that will be upgraded and ask for a confirmation. Simply press Y to confirm. If you’d like to see the full history of upgraded packages, point your text editor to /var/log/apt/history.log.

How to update OS version from a Ubuntu server using apt-get

First, you must make sure that your server packages are up to date. You can do this by running the command apt-get update && apt-get upgrade.

do-release-upgrade
This command will start the upgrade process of the server. Conveniently for those running the system update over an ssh session, the server will provide you a new ssh port and connection in case you lose the initial connection.

reboot
Once the update process is ended, you will be prompted to reboot your server in order to apply the new kernel and any final modifications.