Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to replace the Ali source instance with ubuntu

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to replace the Ali source example of ubuntu. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

There should be a lot of ways to set up ubuntu sources on the Internet, but if you don't figure it out and set it casually, it will not only fail to achieve the desired results, but also cause apt to be unavailable due to some problems.

The most correct way to change the source should be as prompted by the system:

# # a.) Add 'apt_preserve_sources_list: true' to / etc/cloud/cloud.cfg

# # or do the same in user-data

# # b.) Add sources in / etc/apt/sources.list.d

# # c.) Make changes to template file / etc/cloud/templates/sources.list.tmpl

This approach is a bit confused about what should be added to / etc/apt/sources.list.d, and if it is a source file, what is the purpose of the template that is finally changed? I didn't try it either. I'll solve it when I have time.

The following provides methods for setting Ali sources, and other sources can do the same:

1. First check the codename of your ubuntu system. This step is very important, which directly leads to whether your updated source has an effect on your system. Check the method:

Lsb_release-a

For example, my system shows:

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 14.04.2 LTS

Release: 14.04

Codename: trusty

Shows some ubuntu version information, what you need to get is Codename, for example, I am here trusty

two。 Confirm that the Ali source supports:

Visit the following web page: http://mirrors.aliyun.com/ubuntu/dists/

This page shows the various Codename versions of the ubuntu system supported by Aliyun, and make sure that your Codename exists in the page (usually)

two。 Back up the system source:

Cd / etc/apt

Sudo mv sources.list sources.list_bak

3. Add a new source file:

Sudo vi sources.list

And add the following: note that the trusty of each line should be replaced by the Codename you can see in the first step

Deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe

Deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe

Deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe

Deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe

Deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe

Deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe

Deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe

Deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe

Deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe

Deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe

4. Saved and sudo apt-get update, updated successfully

5. The following configuration scripts are provided:

1 Codename=$ ((lsb_release-a) | awk'{print $2}'| tail-n 1)

2 echo "\

3 deb http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe

4 deb http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe

5 deb http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe

6 deb http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe

7 deb http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe

8 deb-src http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe

9 deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe

10 deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe

11 deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe

12 deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe "> sources.list

13 apt-get update

Sudo can run the script (note that it is best to back up the sources.list before running)

This is the end of the article on "how to replace the Ali source instance of ubuntu". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report