After installing Ubuntu server, the very first thing we need to do is to replace the mirror sources to domestic ones (such as aliyun). However, in the command interface, it is a tedious work to type numbers of long URLs into the sources.list, so I copy the source file from my USB disk. And if you have a GUI, it's more efficient to copy the URLs from this page.
-
Check the codename
Use the command
Ubuntu~$ lsb_release -c
to check the codename of your system
and the interface will show as:
Codename: xenial
The xenial
is a codename for Ubuntu 16.04, and may vary with different systems. And for you, it may be bionic
or others.
Remeber it, which will be used next.
-
Create a sources.list in a GUI
Add the following content to the sources.list:
deb http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse
Remember to replace the string codename
to your real codename.
-
Put your sources.list to the USB disk
Make sure that your USB device is NTFS or FAT32 file system, for that the Ubuntu don't support a exFAT system by default.
-
Mount the USB disk to your Ubuntu
See details in: USB Disk Mounting in the Ubuntu Server and you will mount the U-disk to /mnt/usb
-
Bakeup your legacy sources.list
Use the command:
Ubuntu~$ sudo mv /etc/apt/sources.list /etc/apt/sources.list.back
Ubuntu~$ sudo cp /mnt/usb/sources.list /etc/apt/sources.list
to rename your legacy sources and put the new list to the dirtionary.
-
Update the mirror sources
Use the command:
Ubuntu~$ sudo apt update
Ubuntu~$ sudo apt upgrade
to update your apt sources and upgrade software packages.