[linux] apt-get install failure solution and parameter analysis

Ubuntu fails to use apt-get install? This article helps you understand the principle and solve the problem!

The failure of apt-get install is usually a problem with the apt source. Downloading from the official source of Ubuntu is not only very slow, but also unstable. Therefore, in order to download quickly and successfully, we need to add a domestic mirror source. Domestic image sources such as conda and pip generally need to be added in order to download packages such as pytorch.

1. Sources.list file analysis

Command Line URL Version Information Category 1 Category 2 Category 3 Category 4
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted

Parameter meaning

  • deb downloads the binary file or precompiled file of the corresponding software package
  • deb-src downloads the source code file of the corresponding software package

There are four main categories, representing different types of software packages. They are:

  • Main - Free and open source software supported by specifications
  • Universe - Community maintained free and open source software
  • Restricted - driver for proprietary devices
  • Multiverse - Software restricted by copyright or legal issues

The result of the example in the above table is equivalent to finding the software package at these two addresses:
http://cn.archive.ubuntu.com/ubuntu/dists/xenial/main

http://cn.archive.ubuntu.com/ubuntu/dists/xenial/restricted

Reference link: Simple analysis of sources.list content under ubuntu

2. Back up /etc/apt/sources.list in ubuntu

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

3. Edit sources.list

  • Tsinghuayuan
    official help document: https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
  • Alibaba Cloud Source
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

4. Update source

sudo apt-get update

Parameter meaning

  • Ign: Indicates that there is no update or the update is irrelevant or unnecessary.
  • Hit: Indicates that the URL is connected
  • Get: Indicates that there is an update and it can be downloaded
  • Err: Indicates that the target URL connection failed

5. File location of apt-get install

  • The storage location of the downloaded software: /var/cache/apt/archives

  • The default location of the software after installation: /usr/share

  • Executable file location: /usr/bin

  • Configuration file location: /etc

  • lib file location:/usr/lib

6. Other domestic mirror sources

Alibaba Cloud official mirror station address: https://developer.aliyun.com/mirror/
Alibaba open source mirror station: https://developer.aliyun.com/mirror/
Huawei open source mirror station: https://mirrors.huaweicloud. com/
Tencent open source mirror station: https://mirrors.cloud.tencent.com/NetEase
open source mirror station: http://mirrors.163.com/Sohu open source mirror station
: http://mirrors.sohu.com/Tsinghua
University open source mirror site: https://mirrors.tuna.tsinghua.edu.cn/Huazhong
University of Science and Technology open source mirror site: http://mirror.hust.edu.cn/Zhejiang
University open source mirror site: http://mirrors. zju.edu.cn/Beijing
Institute of Technology open source mirror site: http://mirror.bit.edu.cn/China
University of Science and Technology open source mirror site: http://mirrors.ustc.edu.cn/Beijing
Foreign Studies University mirror site: https://mirrors.bfsu.edu.cn

Guess you like

Origin blog.csdn.net/weixin_43693967/article/details/123713450