Update Ubuntu System & Replace Mirror Source

Keywords: Linux Ubuntu

1. Upgrade the ubuntu version

premise

You can upgrade directly from Ubuntu 18.04 or Ubuntu 19.10 to version 20.04. If you run any previous release, you must upgrade to 18.04 or 19.10 first.

backups

First and foremost, make sure you back up your data before making a major upgrade to your operating system. If you're running Ubuntu on a virtual machine, you'd better take a complete snapshot of the system first so that you can quickly recover your machine if problems arise with the system upgrade.

Update Package

$ sudo apt update
$ sudo apt upgrade
$ sudo apt full-upgrade

apt full-upgrade may remove unnecessary packages.

Remove any packages that are automatically installed but no longer dependent on any packages:

$ sudo apt --purge autoremove

Upgrade Ubuntu

Upgrading to the latest Ubuntu version is a simple and straightforward process. Execute do-release-upgrade from the command line to upgrade. do-release-upgrade is "update-manager-core"A part of the package that is already installed by default on most Ubuntu systems. If for some reason the package is not installed on your system, install it with the following command:

$ sudo apt install update-manager-core

Start the upgrade, enter:

$ sudo do-release-upgrade -d

This command will disable all third-party software sources and point the apt list to the focal software source. You will be prompted several times to confirm, just press y all the way.

Confirm Upgrade

After the upgrade is complete, restart the system and enter the following command in Terminal to query whether the upgrade was successful.

Check the Ubuntu version:

$ lsb_release -a

Output:

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

Your new Ubuntu 20.04 installation is complete.

2. Change mirror source

Ubuntu defaults to the official source server in Europe, where access from home is slow. Ali, NetEase and some key universities in China also have Ubuntu sources, so it is best to replace the official source with the domestic source after installing the Ubuntu system. To avoid installation problems and improve download speed, let's take Tsinghua source as an example.

Back up source files

Back up the original source and back up the previous source in case it can be used later.

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

Get Ubuntu Version Number

Each Ubuntu release has its own code number. We need to find the corresponding source by the Ubuntu code on our computer. Ctrl+Alt+T opens the terminal and executes the following commands:

lsb_release -a

Output:

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

My version number is Ubuntu 20.04 LTS.

image source

We open the official source website of Tsinghua to see the mirror source of our version number: Tsinghua Source

Replace Source

Open the / etc/apt/sources.list file, replace the contents of the file with the following, and save.

$ sudo vim /etc/apt/sources.list
# Source mirroring is commented out by default to increase apt update speed, uncomment yourself if necessary
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# Pre-release software source, not recommended
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

Update Package

$ sudo apt update
$ sudo apt upgrade

Posted by mrfritz379 on Sat, 09 Oct 2021 09:34:45 -0700